From nobody Sun May 5 14:55:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+46835+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+46835+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1567638271; cv=none; d=zoho.com; s=zohoarc; b=RK4WjMeKBOiTT3faYZN9wWx5Q8tYr6EReckvQQEaqCshZ4b1kjWwrfXwxTA+CKg0bce92yGzFZYP5pw9y4v/ufgByD6TDi9vnBH5ZOt51NbbBzzhZ3xgm9M4RWeMntgK7c8JD/GTll/f+kP95cEr5NzAxzCdkLljHKB2Jax0znc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567638271; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=NNqyq84tDIZrbDSP8RAtzPuzPZCPvgq2hwcJWS3xJq0=; b=d+KdvBvf8wS+Xf9HifwcZ/EoFksa9qvuflzhlik5JZ82as+lk262X8plC7jVj2mIOofBDlyYfphvEXv1eW+YNzagsyA9f0W4FK2Kq7BG3CsYBoICDsa88j8fUEVO8gvfDk5+CsvxjOTmfcvd1A6lVSzdCz4UCDyUxfSteHT0+I8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+46835+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1567638271011620.9609472113628; Wed, 4 Sep 2019 16:04:31 -0700 (PDT) Return-Path: X-Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by groups.io with SMTP; Wed, 04 Sep 2019 16:04:30 -0700 X-Received: by mail-pg1-f195.google.com with SMTP id l21so269265pgm.3 for ; Wed, 04 Sep 2019 16:04:30 -0700 (PDT) X-Gm-Message-State: APjAAAXGVHYmHvffQ4dZ8x0hDYfokKWfNenK2G35gSkmIqHCZX+6LETh Hv1TkArUcXZteE/9GW6UbPGi/wpOUZNOycS8 X-Google-Smtp-Source: APXvYqzMkC1ZbF7yMn1O2zQToaHZ8Fi63TTJqSWWTqUgmlXhu4vmdLObjYda8CYaXxWAchsegWm2xA== X-Received: by 2002:a65:4c4d:: with SMTP id l13mr472430pgr.156.1567638269041; Wed, 04 Sep 2019 16:04:29 -0700 (PDT) X-Received: from e111045-lin.nice.arm.com ([104.133.8.102]) by smtp.gmail.com with ESMTPSA id a128sm117013pfb.185.2019.09.04.16.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 16:04:27 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, lersek@redhat.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH] ArmVirtPkg/ArmVirtPrePiUniCoreRelocatable: revert to PIE linking Date: Wed, 4 Sep 2019 16:04:23 -0700 Message-Id: <20190904230423.24661-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1567638270; bh=iMAVrl6fllmC2lsOSUQlvd45DdBGi51GwLU5HSx7v8E=; h=Cc:Date:From:Reply-To:Subject:To; b=fN4hdfDpqANxDIr0/Howz5vqaycIyuyg+ZTNRyyN8SjUpAf3XGWs/T2WpHlm7Iagcw7 diZsaDGQZsdVqh1pN2FixUX5PpPOzsIwJ8Vd8LOcxqmXN1chiuyoiAcb0hpTRwKBXYVi/ huuAMZPFa723T1VcpDuYb4WOsfkrg2SzX08= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Laszlo Ersek Acked-by: Leif Lindholm --- 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/ArmVirtP= kg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf index 683397b7afd1..9e58e56fce09 100755 --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf @@ -97,4 +97,4 @@ gArmTokenSpaceGuid.PcdFvBaseAddress =20 [BuildOptions] - GCC:*_*_*_DLINK_FLAGS =3D -shared -Wl,-Bsymbolic -Wl,-T,$(MODULE_DIR)/Sc= ripts/PrePi-PIE.lds + GCC:*_*_*_DLINK_FLAGS =3D -Wl,-Bsymbolic,-pie,-T,$(MODULE_DIR)/Scripts/P= rePi-PIE.lds --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#46835): https://edk2.groups.io/g/devel/message/46835 Mute This Topic: https://groups.io/mt/33144570/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-