From patchwork Thu Jul 14 13:16:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 72010 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp74771qga; Thu, 14 Jul 2016 06:16:33 -0700 (PDT) X-Received: by 10.98.17.152 with SMTP id 24mr12425997pfr.13.1468502187911; Thu, 14 Jul 2016 06:16:27 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id u87si4015388pfa.1.2016.07.14.06.16.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jul 2016 06:16:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 54E001A1F35; Thu, 14 Jul 2016 06:17:07 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E900B1A1F33 for ; Thu, 14 Jul 2016 06:17:05 -0700 (PDT) Received: by mail-wm0-x22c.google.com with SMTP id i5so112819780wmg.0 for ; Thu, 14 Jul 2016 06:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kAuewZLNFyKSBevAHlHQ0UI1x54/26h5odS5XK4N+s4=; b=g5Epb9E2fs9cahVDGeylMgu7MDngTqkYduUeZdCegAuh6swyAWANRUY63tbJuN8LWT la3dYyNeI4HDgUlDcDmzweBQC6o/Knf2wmSOxvWCWrAXX205gaMpjmiCDcUv2OdPFETG TAvePs8EuK3KqooFxMeu58m5OPOU6N7jMRi9A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kAuewZLNFyKSBevAHlHQ0UI1x54/26h5odS5XK4N+s4=; b=GMghC4llRwAefWCqhr+M2RoNv5N6uXCGOqdYTkZNLOHodLBxRlUgC4LHzJeg15nOcN /4OBlnYqKXt5sPzs3Ez4XG1OyZLcOVVyQ3rRyDmByDE7s4ebUe2B1U7rDSiQ3AIFWij1 RR4YxRulbttqtjXUV9G5ELN50ZlEaDO2OJ6Qwj8aiFDQm/AzBE8H0U501uzUsZrojp2U b1r83G4fDVfh652/HG0/R52toWOx37UIPcd1WDER2jZ0jLgfGdYZInRHvan4EvQYtN1y DvG2PQblisYOBJdM8fT6eEmbVlrGcBuqBa03WqFa51AFGE2Kd+GuXexrZ1wz6c2I6Evl 4q3w== X-Gm-Message-State: ALyK8tI9eeIwz0J6ivMavVoefC+s1J0BhSTs19/7QqUHKbAl6h857qZMUKV8XmRkbqOVEUU8 X-Received: by 10.28.154.208 with SMTP id c199mr20566626wme.102.1468502178187; Thu, 14 Jul 2016 06:16:18 -0700 (PDT) Received: from localhost.localdomain ([188.203.148.129]) by smtp.gmail.com with ESMTPSA id q69sm43232902wmd.4.2016.07.14.06.16.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jul 2016 06:16:17 -0700 (PDT) From: Ard Biesheuvel To: steven.shi@intel.com, yonghong.zhu@intel.com, liming.gao@intel.com, michael.d.kinney@intel.com, jordan.l.justen@intel.com, lersek@redhat.com, afish@apple.com, edk2-devel@lists.01.org Date: Thu, 14 Jul 2016 15:16:09 +0200 Message-Id: <1468502169-15248-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468502169-15248-1-git-send-email-ard.biesheuvel@linaro.org> References: <1468502169-15248-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 5/5] BaseTools/tools_def: switch GCC/X64 to the PIC small model X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The ordinary small code model for x86_64 cannot be used in UEFI, since it assumes the executable is loaded in the first 2 GB of memory. Therefore, we use the large model instead, which can execute anywhere, but uses absolute 64-bit wide quantities for all symbol references, which is costly in terms of code size. So switch to the PIC small code model, this uses 32-bit relative references where possible, but does not make any assumptions about the load address (i.e., all absolute symbol references are 64-bits wide). Note that, due to the 'hidden' visibility pragma introduced in an earlier patch, there is no need for the EDK2 build system to deal with GOT related ELF relocation types. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- BaseTools/Conf/tools_def.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index 3bff65b862a2..529a29402968 100644 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -4353,7 +4353,7 @@ DEFINE GCC_AARCH64_RC_FLAGS = -I binary -O elf64-littleaarch64 -B aarch64 DEFINE GCC44_ALL_CC_FLAGS = -g -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -c -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings DEFINE GCC44_IA32_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables -DEFINE GCC44_X64_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) -m64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -Wno-address -mcmodel=large -fno-asynchronous-unwind-tables +DEFINE GCC44_X64_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) -m64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -Wno-address -mcmodel=small -fpic -fno-asynchronous-unwind-tables DEFINE GCC44_IA32_X64_DLINK_COMMON = -nostdlib -n -q --gc-sections -z common-page-size=0x20 DEFINE GCC44_IA32_X64_ASLDLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_COMMON) --entry ReferenceAcpiTable -u ReferenceAcpiTable DEFINE GCC44_IA32_X64_DLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_COMMON) --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map