From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=R9n8Gwab; spf=pass (domain: linaro.org, ip: 209.85.128.66, mailfrom: ard.biesheuvel@linaro.org) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by groups.io with SMTP; Thu, 05 Sep 2019 07:25:54 -0700 Received: by mail-wm1-f66.google.com with SMTP id t9so3295620wmi.5 for ; Thu, 05 Sep 2019 07:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VsxI0YtbN5THpOzt2RSMxzLyi98Ti3PO3LlGFTPcQus=; b=R9n8GwabgMqRUyprP2mkv1xBcXCrdh2MnRrp6zZlc26Us3/XrsVpFBlOMVQ5drDEW/ cgN0f7N/YDSIIACYmddqd4NiV4RO/JEa/S7tgqV+BEl8x2yyuVOJT2BW2S7lBOf3XQFM ZFzL0+qkqu7s4OvQLjHpyYC9FaJiPyXdt+nG4aEanfao0roxxV6id2VkfXaLV6pImmqK 3eNA+hokE3XJwJAJpeKh5kifntwHtliXQiBMq82mhOK2UdriHHQ1UZfvVWgjHWj/NMeO koERBTPM6bfrdlw2S3kBSayXZ7BWBsVD7pQXwaYmxK9omcxV7pfBojLGQVBgYFYF9NiL x89A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VsxI0YtbN5THpOzt2RSMxzLyi98Ti3PO3LlGFTPcQus=; b=tJxmP2sZDKeK1CWZsD9T7Z/cHaodAuQt7po9T5DKipj95gcJYrMMa2leGfatpf9Jia x82iDM+8ZYweEWr+OAZVpXAriOvd6AaDrMV84x0q+c0e0e59USm3T1YVWJdxmTSrD44g D+4ijhagMGhkatP4BECgKxoN88SoJ8SjQn5bpGPhXNVMgIY//vIvS4KkTR9b+Lofjy6X lrxtduxnde8iqinDwiCRXR33IYSktNBDI75OPCLBjmumVJqXR1CsserBJwOf0R9x0fAS fKeNnvtfgATBHqs813Q9qjr3E5uSJ3jyb7xHYyI0Cik3mYgfnI1qecTTTLBVWubmhyKK lxJg== X-Gm-Message-State: APjAAAU89UmXIht54ixJ3gXAMht+ZeDEj5Ege9F8N3KOrjhujHIuSiWM C1HWtOkD5rRgKv4hhUIUGlkgjE20h0ss3G0+HIAMPw== X-Google-Smtp-Source: APXvYqwffyB2ajJbppqU2IrgAHFmdblOV12MuDI9bZdyqM7QzIHyTNqZBLnNxdMLS4T0mx9Z8e2fVo53+1xVtiqXoPo= X-Received: by 2002:a1c:2546:: with SMTP id l67mr3396041wml.10.1567693552534; Thu, 05 Sep 2019 07:25:52 -0700 (PDT) MIME-Version: 1.0 References: <20190904230423.24661-1-ard.biesheuvel@linaro.org> <20190905141923.GX29255@bivouac.eciton.net> In-Reply-To: <20190905141923.GX29255@bivouac.eciton.net> From: "Ard Biesheuvel" Date: Thu, 5 Sep 2019 07:25:39 -0700 Message-ID: Subject: Re: [PATCH] ArmVirtPkg/ArmVirtPrePiUniCoreRelocatable: revert to PIE linking To: Leif Lindholm Cc: edk2-devel-groups-io , Laszlo Ersek Content-Type: text/plain; charset="UTF-8" On Thu, 5 Sep 2019 at 07:19, Leif Lindholm wrote: > > On Wed, Sep 04, 2019 at 04:04:23PM -0700, 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.in > > 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 > > We already merged a fix for AARCH64 though - could/should this be > active on ARM only? > > A problem I have with this patch is that ArmVirtQemuKernel curently > doesn't boot on my qemu (with/without kvm, built with GCC5 or CLANG38, > with or without this patch): > ProcessPciHost: Config[0x4010000000+0x10000000) Bus[0x0..0xFF] > Io[0x0+0x10000)@0x3EFF0000 Mem32[0x10000000+0x2EFF0000)@0x0 > Mem64[0x8000000000+0x8000000000)@0x0 > MapGcdMmioSpace: failed to set memory space attributes for region > [0x4010000000+0x10000000) > > ASSERT_EFI_ERROR (Status = Unsupported) > ASSERT [PciHostBridgeDxe] > /work/git/edk2/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c(293): > !EFI_ERROR (Status) > qemu-system-arm: terminating on signal 15 from pid 4680 (killall) > Does it work with -M virt,highmem=off ?