From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Thu, 05 Sep 2019 12:33:07 -0700 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F24380038D; Thu, 5 Sep 2019 19:33:07 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-133.ams2.redhat.com [10.36.116.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E6D75C1D4; Thu, 5 Sep 2019 19:33:06 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH] ArmVirtPkg/ArmVirtPrePiUniCoreRelocatable: revert to PIE linking To: devel@edk2.groups.io, ard.biesheuvel@linaro.org Cc: leif.lindholm@linaro.org References: <20190904230423.24661-1-ard.biesheuvel@linaro.org> From: "Laszlo Ersek" Message-ID: <7dff2d0c-eb94-62a8-f07a-705050a71645@redhat.com> Date: Thu, 5 Sep 2019 21:33:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190904230423.24661-1-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Thu, 05 Sep 2019 19:33:07 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 09/05/19 01:04, Ard Biesheuvel wrote: > In some cases, the CLANG38 toolchain profile in LTO mode emits GOT > based relocations in spite of our attempts to avoid this, by using > hidden visibility, -Bsymbolic etc. > > On AARCH64, we managed to work around this by processing the GOT > based relocations in GenFw. As it turns out, the same issue exists > on 32-bit ARM, but unfortunately, we cannot use a similar trick to > get rid of the GOT entry, and the relocation metadata is insufficient > to locate the GOT entry in the binary. > > A bit of trial and error reveals that switching the linker options from > -pie to -shared in commit e07092edca8442db4a941dbeea0cd196c7bf8ec9 was > not the best approach, and instead, we can pass -pie to the linker > directly (using -Wl,xxx) rather than to the compiler directly, which > turns out to massage the linker in the right way, and prevents if from > emitting GOT based relocations. Your mileage may vary ... > > Signed-off-by: Ard Biesheuvel > --- > Let's test this on a couple of different Clang versions. If it still > produces problems, the only other way I see is to disable the builds > of platforms that incorporate this module for ARM/CLANG38 [which is > not the end of the world] > > ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf > index 683397b7afd1..9e58e56fce09 100755 > --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf > +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf > @@ -97,4 +97,4 @@ > gArmTokenSpaceGuid.PcdFvBaseAddress > > [BuildOptions] > - GCC:*_*_*_DLINK_FLAGS = -shared -Wl,-Bsymbolic -Wl,-T,$(MODULE_DIR)/Scripts/PrePi-PIE.lds > + GCC:*_*_*_DLINK_FLAGS = -Wl,-Bsymbolic,-pie,-T,$(MODULE_DIR)/Scripts/PrePi-PIE.lds > Sorry for being late to this patch, I can see [*] it's upstream alrady. Nonetheless: Acked-by: Laszlo Ersek [*] Not from my inbox though -- I've got again too much on my plate and am fetching email in batches. But, between my rebasing of "ArmVirtPkg/PlatformBootManagerLib: unload image on EFI_SECURITY_VIOLATION", building it, and attempting to push it, you had pushed this one -- and I did notice that. :) Thanks, Laszlo