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=OnUVLDIj; spf=pass (domain: linaro.org, ip: 209.85.128.67, mailfrom: leif.lindholm@linaro.org) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by groups.io with SMTP; Thu, 05 Sep 2019 07:19:27 -0700 Received: by mail-wm1-f67.google.com with SMTP id k1so3038077wmi.1 for ; Thu, 05 Sep 2019 07:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XcstBGwQLh56DiTvok+/wNF9SxNh+H97mUhOVrE2lso=; b=OnUVLDIje56q/0+4VyhF9smBZY43pr+yvZPwwkXA86PT/oY8cIGtzTeY1rF9Qw/qW7 lYOCI347qzeF7UQbg+hn6CIJwgwc/k19w+cRnIHbLn7eWzKkHkpJ8JNZpfJPA3BYoag4 8BLUFWX1tzgWCiNLlmhfFZqFrFJwuEK5UkzEfy4DudSEOQpONBGdbIXEd3SMZfjFFjSY o0vJOZTBsG7dHKo4D8dhP8v6RENFuMkizJ0ik0/WzAM+8ZHFROWgEkbgn8Ch6tMmr3Vq aJ6Apat/N6Bno3vVsu7uWBKAK09X/bRrjMs+6TzqmP1VypSJBAt/NsincDlVqXXcVJHT a3ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XcstBGwQLh56DiTvok+/wNF9SxNh+H97mUhOVrE2lso=; b=NpO6ZBz6BzwPkI2BBwmmMqy1JBqxzWQNDtqsYIFfmWFw2qLnLc764k+toRywmJrIXz T0CqDTRrGRZkh6chpfFSWzuGWLlckoyBHBY8P8vRRrQMxt1joI6VSK3omFcTQsdpEZBH xgI0ckbnS+dHrB3Sl0srdP5drPv3HiYZVPW/B+15KCR3zHgSsxJfkVNwfTDKC5MfhnXX WdInhqc4ixV7ZIIp376Ov641GnO88Te0nrED/OmX658xISimTVU3d91/6Ppcv1udGoN0 +PG3EogYcf9GXs/NWOQWngr6BmD1ra1sc2LKJyMo1u2GFof508vn4j8kHlqlt7eaHlK4 18zg== X-Gm-Message-State: APjAAAVrtzM6pIx0vP2BY/bdLIBb28heXD9GIa1wj93yTy7HK72oV8q7 P80rH8GI9jBPHBmJ9iMOu4IMLA== X-Google-Smtp-Source: APXvYqyHZwxJRrH0y2QMVaJwrbuoi5teKhW0Ws+5I1Q9IqU/WieInPgaF+Mv+K7N4GTkCjb/qFJ51g== X-Received: by 2002:a7b:c766:: with SMTP id x6mr3441645wmk.51.1567693165461; Thu, 05 Sep 2019 07:19:25 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id z189sm4045639wmc.25.2019.09.05.07.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 07:19:24 -0700 (PDT) Date: Thu, 5 Sep 2019 15:19:23 +0100 From: "Leif Lindholm" To: Ard Biesheuvel Cc: devel@edk2.groups.io, lersek@redhat.com Subject: Re: [PATCH] ArmVirtPkg/ArmVirtPrePiUniCoreRelocatable: revert to PIE linking Message-ID: <20190905141923.GX29255@bivouac.eciton.net> References: <20190904230423.24661-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20190904230423.24661-1-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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) / Leif > -- > 2.17.1 >