From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x22f.google.com (mail-io0-x22f.google.com [IPv6:2607:f8b0:4001:c06::22f]) (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 0671A2041D9EA for ; Fri, 31 Mar 2017 02:39:06 -0700 (PDT) Received: by mail-io0-x22f.google.com with SMTP id z13so36239491iof.2 for ; Fri, 31 Mar 2017 02:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9Lv5RRqJGnC6L62ttYdpErsjmBYYaxJZOtzPfamdngY=; b=gGHKjFSYL9vJmnLU0xnO9Fuw+FGIXhfOTtKjKElmwbI1jpWLWLKffZH/KMMa3OaUxr vqNoTiRJaIaQB/3VVytgQzZ+5h0zC4sn9IvBY5cLzEhIdWkYng/wA50Vt/IMH/BRDzgo +MK1xp24BBFDHPbm3r1hcLhnQ84hoMlXxVW7o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9Lv5RRqJGnC6L62ttYdpErsjmBYYaxJZOtzPfamdngY=; b=bhwcw90LHYZPDktZkcfmP5VlYAvYZfm7eE3SPbVS88ZJcxpX43kuU2XSIDAV8DIiLu dyTSaERAV4ys30BJUMFmL8LggeVJRxofPPn+bBDflcMYzQJB4EhZkW67hLOVyGJOBD2O qZLkjbKkuNRHQHcWMya1f9jguhn3q/ZjegHIOOmCM33o4KdHVEaRFKxcBmBvy7NX4eAd Sw3aj0zhs9Eyh87Yx1TB8FkdnO0jC9V7YTf+IdR52A+tgnocwOjTRUh+A42/6EMDRI2H DME6XURe/Y1PJEntPKCMKxH2D1ty7SXyMbZPa5Elj3nhhdInYB26WTg/CMm/kX9aMbf2 jlOA== X-Gm-Message-State: AFeK/H1JvY3KjyxhfPEW1LImJEFsMP8zX2gnCa3oLWTkSCWNZXcGNULhrmixdbhYCQ4ktAIAQfgO155Rwl7eVvEk X-Received: by 10.107.132.155 with SMTP id o27mr1969744ioi.138.1490953145287; Fri, 31 Mar 2017 02:39:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.10.27 with HTTP; Fri, 31 Mar 2017 02:39:04 -0700 (PDT) In-Reply-To: <2db957f3-f5a1-0ad6-5684-a0f489cabeec@redhat.com> References: <20170331084013.4203-1-ard.biesheuvel@linaro.org> <2db957f3-f5a1-0ad6-5684-a0f489cabeec@redhat.com> From: Ard Biesheuvel Date: Fri, 31 Mar 2017 10:39:04 +0100 Message-ID: To: Laszlo Ersek Cc: "edk2-devel@lists.01.org" , Leif Lindholm , Marc Zyngier , "Zhu, Yonghong" , "Gao, Liming" Subject: Re: [PATCH v2] BaseTools/GCC AARCH64: force disable PIC code generation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Mar 2017 09:39:06 -0000 Content-Type: text/plain; charset=UTF-8 On 31 March 2017 at 09:59, Laszlo Ersek wrote: > On 03/31/17 10:40, Ard Biesheuvel wrote: >> As a security measure, some distro toolchains now default to PIC code >> generation, allowing executables (as opposed to shared libraries) using >> the objects to be built as PIE binaries, which can be loaded at a random >> virtual offset. >> >> However, our ELF to PE/COFF generation code does not deal with the >> resulting relocation types (i.e., GOT based), and so the use of PIC code >> leads to GenFw errors. >> >> Given that >> a) our non-PIC PE/COFF executables are already relocatable, >> b) PIC code leads to all symbol references to be indirected via GOT >> entries containing absolute addresses, each requiring an entry in the >> relocation table, >> c) the AArch64 ISA makes it perfectly feasible to built PIE executables >> from non-PIC code, >> >> there is absolutely no upside to using PIC code for building EDK2 modules, >> and so we're better off simply disabling it unconditionally. >> >> Note that when running under the OS, the GOT has an additional advantage, >> i.e., that all .text/.rodata pages remain clean and so can be shared between >> processes. This does not apply to the UEFI environment, however. >> >> 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(-) >> >> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template >> index 0aabdeb2d973..2c5cd5808912 100755 >> --- a/BaseTools/Conf/tools_def.template >> +++ b/BaseTools/Conf/tools_def.template >> @@ -4341,7 +4341,7 @@ DEFINE GCC_X64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-ad >> DEFINE GCC_IPF_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency >> DEFINE GCC_ARM_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-builtin -Wno-address -mthumb -mfloat-abi=soft >> DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access >> -DEFINE GCC_AARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char -ffunction-sections -fdata-sections -fno-builtin -Wno-address -fno-asynchronous-unwind-tables >> +DEFINE GCC_AARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char -ffunction-sections -fdata-sections -fno-builtin -Wno-address -fno-asynchronous-unwind-tables -fno-pic >> DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align >> DEFINE GCC_DLINK_FLAGS_COMMON = -nostdlib --pie >> DEFINE GCC_DLINK2_FLAGS_COMMON = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds >> > > Sounds convincing enough to me. I find it quite annoying that such an > important property of code generation (-fpic or -fno-pic by default) > varies across distros. Well, security. > > Acked-by: Laszlo Ersek > Thanks, pushed as c2d56a894b32