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=vf4vv29V; spf=pass (domain: linaro.org, ip: 209.85.221.68, mailfrom: ard.biesheuvel@linaro.org) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by groups.io with SMTP; Thu, 05 Sep 2019 07:27:49 -0700 Received: by mail-wr1-f68.google.com with SMTP id h7so3023640wrt.13 for ; Thu, 05 Sep 2019 07:27:49 -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=VGePhlEgoVAxON9FLhxEeM207GTrTb2zUMhJFFzKsQA=; b=vf4vv29V403xYOzUjzy5BgYCC3ixa+NewAOABNS6MF1dREFb+rAWOXm+nhKJuu/nQW XJa6OBSFFzuD+W1Gw9z9nrcy66+pVfX8wnkI89DaTQUnC9eE+Mr0ErZGTy81gNVLQ2Fj 5PkuQ7RK6CwzDhPfjqZWmZiW2ZsBLBB76mmhS8Hnh2mlDdIVgX5xUfvdk0phfezbT1qL G+GIQMK9DgzUMW+k3Bnb9FTGnqS9hCzOR1xd1W71ZQrzdspqwttDLL/cy+BFoB5Uu7RH meZ3Byvjlk5A/pcfXbFWqBdULP77khJaDoKodviiDdvXyEBG0riak6GCvJfzNx61sdx1 WMkg== 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=VGePhlEgoVAxON9FLhxEeM207GTrTb2zUMhJFFzKsQA=; b=p1XGSzOLjdd45LlJG7pqM69KWGfzDHz4H5jy54GTkYbvJ7Dq4bhhMWQ1tbsNFy9Yp0 b9t0uTVTmLdRc3cCb/2qfih9pD3WTjzNv5PI6hJMU56ldl0XPVmZ1uaBNKHQNAAVCQVQ l6qs7zFwO8Qvr02+vvA4PqLrQ1uDup//Xm5DOjGL2Jy2roo7fuiL59guLNalWaAzmoRS EXXtUoMi9KYMrGn9vg+iLn6LWpOGglVsubZjIs0XE/FIn4AUcPR64ECSCXS6JoJmKjX+ t5pa+UzCM6GCW416TqVJbwwsUKnB6Svq6RZNccalXkBHeO7Yz8kJpTk7UQdhgDvCBVMZ YU5g== X-Gm-Message-State: APjAAAV7qVWtsi6wkK4qEUiCrXXWfvRiY3xn7ivSWVyR6zOGHBOZBL1f qQ8nkkvUP+F6gZAjmvr9ArmeVHGq0mvKM1qtbboEPw== X-Google-Smtp-Source: APXvYqxUVVKOk7eLz3lpRrb/rha2oPAVv3zxjOgkXKoRPkeUw07frguNxbDABbM+OuhT4SQKfchn7ia0+o474KxjviM= X-Received: by 2002:adf:ee50:: with SMTP id w16mr3080377wro.93.1567693668193; Thu, 05 Sep 2019 07:27:48 -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:27:35 -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? > I'd like to keep the GenFw change, since we've confirmed that it correctly handles GOT based relocations should they appear. But if this fix works for all Clang versions, I'd rather have it active for AArch64 as well, since the best solution is still not to have any such relocations in the first place. > 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) > > / > Leif > > > -- > > 2.17.1 > >