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=IuqD1t1w; spf=pass (domain: linaro.org, ip: 209.85.221.65, mailfrom: ard.biesheuvel@linaro.org) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by groups.io with SMTP; Fri, 06 Sep 2019 15:47:57 -0700 Received: by mail-wr1-f65.google.com with SMTP id h7so8086240wrt.13 for ; Fri, 06 Sep 2019 15:47:57 -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=vvfgdTCoztAh0Mh8u4yBdfJW+8ZCz7jhDszJI9AREck=; b=IuqD1t1wGqtnekjZI65LKAJHVKvix0AmYA1hO8gVusb4SBn0iXmKfpvVUxDTHuc2OJ JLSOX1QDToC7J2mOo6EHQtZE5MnszGk77G9oOvrjcVrkYTHqVy3J2WN/FJ5JcS9TYbTK vy5CKFyap2HaVML4V7Lzk6xNYZAAPTrBtZ6Nz2co5tg4JzyVHlXK1xt97HwT/7wj2Id4 O+NKMAoMoAUZRqHKcRAV2qvDvcst0whrfKAToGsSdkRqm4npo4XWXwmFpxWGnprPTQZc QZfdZns1Bt6a/UYpPjgPy6LelYkfi3/k4Xvm041UX5Nihn0SBmg/PBhlMXbtbmVXhtln vSLw== 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=vvfgdTCoztAh0Mh8u4yBdfJW+8ZCz7jhDszJI9AREck=; b=pVy/IgH7GjMmjkSf2iXi8usV9wxZr2QVZz2te7ZiTSxtYMYbOj1Jy6iWpC8wyPU9IY XGHrUHEJsAKVjPld5esJObKouPD/xZIyCzYB0mIMWkKhJ1upyYksZI9heQvrAYPB+lZB LoFHccd2FJNqih2KRYZ8fwwGjORW78Ovm35Auq1SNv9ZjCcznhdvv14ivKaGfxRUGRAN B0VjrvugvEc9v8jkAjCu/+EfUHMau/VQijGlIClnLPgpiaAB8BAAkwOPZTX4eFYR/BTJ ZZqN6cJH3rE+bo2MetLZd9sbSEahnXAVvlTQyliP3BFUpI8E/7bD9IAl2tFEXZ3/K9OU hqHw== X-Gm-Message-State: APjAAAXRfa62ov1VZU4XuY+ODczmZ5pVLpLWPbHveFNJ1KjJolKGx3+r xMWTxktAKp4t0M1PW8b3VnNX+wWTMWjWyA3Tqsw1Xg== X-Google-Smtp-Source: APXvYqzpaKIy6upgGtGTKPKfZKuCGze8EIrsAmHoi9+DIj2tNS+2361CuwhLmGWRE3RJmJmaEkoZJnVGiCZnZ+DtmxM= X-Received: by 2002:a05:6000:82:: with SMTP id m2mr4084067wrx.241.1567810075935; Fri, 06 Sep 2019 15:47:55 -0700 (PDT) MIME-Version: 1.0 References: <20190904230423.24661-1-ard.biesheuvel@linaro.org> <7dff2d0c-eb94-62a8-f07a-705050a71645@redhat.com> In-Reply-To: <7dff2d0c-eb94-62a8-f07a-705050a71645@redhat.com> From: "Ard Biesheuvel" Date: Fri, 6 Sep 2019 15:47:39 -0700 Message-ID: Subject: Re: [edk2-devel] [PATCH] ArmVirtPkg/ArmVirtPrePiUniCoreRelocatable: revert to PIE linking To: Laszlo Ersek Cc: edk2-devel-groups-io , Leif Lindholm Content-Type: text/plain; charset="UTF-8" On Thu, 5 Sep 2019 at 12:33, Laszlo Ersek wrote: > > 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 > Thanks. Since the patch is already merged, I'll find another patch to attach it to :-) > [*] 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