From patchwork Fri Jul 15 22:16:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 72150 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp21050qga; Fri, 15 Jul 2016 15:17:08 -0700 (PDT) X-Received: by 10.98.84.197 with SMTP id i188mr25307203pfb.43.1468621028371; Fri, 15 Jul 2016 15:17:08 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id d186si65929pfc.72.2016.07.15.15.17.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jul 2016 15:17:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; 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 198.145.21.10 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 A66511A1F3D; Fri, 15 Jul 2016 15:17:50 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x22a.google.com (mail-wm0-x22a.google.com [IPv6:2a00:1450:400c:c09::22a]) (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 192281A1F34 for ; Fri, 15 Jul 2016 15:17:49 -0700 (PDT) Received: by mail-wm0-x22a.google.com with SMTP id f126so40978551wma.1 for ; Fri, 15 Jul 2016 15:17:01 -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=jRixwpNXhMapPIo9WnLQYc0FL3XCzn2hBCyqInD1dPA=; b=Le5fzPm6i0Gs7BS8i1dZegjAmS7JvPFJPorEJJ+kHHLF2Vn5PQcoQv+OgX3sxENqCh 6s2snUctlYJMAQFQlR7+m7brY289KIlAXZp9M3iYvtTemAL2UpgCyZH3pY1z4ADHMogt RBt6CfZeeBQh4k/G7snUFPBxoir78AmHunfPE= 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=jRixwpNXhMapPIo9WnLQYc0FL3XCzn2hBCyqInD1dPA=; b=f9mix3dO0sR6yenOyiXmqHlztItRuZBQlndGRkuaT5opWYnnEmg+F86zwDixyjQ3tn Bu2z2Zk7fd767lNOFaXRTSLyhGsbBQUsNrAe/mbC5lbYWhMQEg7uXGdk1BDqMl4+RUNt G2uR8K8fpmrrPBQwskSg+j9d1zPbpHZvI+0+6gr3C0y2dIFHx6m1k7+s+uVyB7gGDpFH Um0jCiciRO2WVY3DXt1A/Z8wzCIKbGaeV169EtXtr7G9kvy+MQ4Col6/ScEHnR/XiU9x uZSD+gvIPIuNCk/VPPn/K5RG9ksqGc+kX+SR5CrcaWjolebywwI42EI3m2fpqK/eKTJh STKA== X-Gm-Message-State: ALyK8tIzUPLObG4ZFI/J/cg2zlJ9MPoY7hi7iAci22L51py4DbRZdW5oyUkuOjrjLHeofcvu X-Received: by 10.194.22.97 with SMTP id c1mr2559571wjf.45.1468621020456; Fri, 15 Jul 2016 15:17:00 -0700 (PDT) Received: from localhost.localdomain ([188.203.148.129]) by smtp.gmail.com with ESMTPSA id kr1sm2736108wjc.46.2016.07.15.15.16.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jul 2016 15:16:59 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com, afish@apple.com, liming.gao@intel.com, steven.shi@intel.com, yonghong.zhu@intel.com, michael.d.kinney@intel.com, jordan.l.justen@intel.com Date: Sat, 16 Jul 2016 00:16:11 +0200 Message-Id: <1468620971-5960-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468620971-5960-1-git-send-email-ard.biesheuvel@linaro.org> References: <1468620971-5960-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 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: bruce@cran.org.uk, pbonzini@redhat.com, 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 Tested-by: Laszlo Ersek --- BaseTools/Conf/tools_def.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.9.1 _______________________________________________ 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 a7da6741611d..17f2207680d3 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))" -Os -maccumulate-outgoing-args -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))" -Os -maccumulate-outgoing-args -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