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=N+WhZA/q; spf=pass (domain: linaro.org, ip: 209.85.215.195, mailfrom: ard.biesheuvel@linaro.org) 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 Received: by mail-pg1-f195.google.com with SMTP id l21so269265pgm.3 for ; Wed, 04 Sep 2019 16:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=58cOFPSie+4X2MU8S76tveH4h/+P/T6HPp9b393gMac=; b=N+WhZA/qPv4SpzV5EHXjjYZbz50umeJav5vW5ePWQHpCyElZGZQw2upWDiQ0tlbGMg AB9oKlbAtCBSHO2YOLvt3+5jRwFA2cIOD36FcGsFXu7v7+CLLpIVuao5RG8Ipm6hoxxd hGpuPlz0h5ULwKmdAboLwt+7iKiatSbEWfNkXhpmrAUfS0R063hPtCT8kWv3+Q+1A3e2 nfpSBXrKZxm9z3KvkiY330XxTGN3OUFtiT8d0l/ewdkOD6NHmSVOpEbE6D+Kb377iI49 HB952kFYxRm15YHj/deXNLEGC/kTjAd3YkZOhBiWdzJciDLmd6aduKxVW5QrUlt9M5Bl 2Jqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=58cOFPSie+4X2MU8S76tveH4h/+P/T6HPp9b393gMac=; b=kia09WnmeiAHfSNyBaO1qhDBRIlkVq6mKB8FbmXQpwDL16Vt4QkR4xE4Crkqavu8kJ xm75zE0Yagde3qFKvUI4UVB2GygqE4taPQyHXk6MMt0l30dH8BoiOOIUYIkUKIKYChqV EmzuM+p3+BZNSFIOtvtDSRodqEdL14UAYrd3FZ9kVJ4RjrsrQddzV2J7TCKtUP79GmKh Pysp76zb4joR72NEdGRvSggopOkJty89Zb5g2Sg8WbDNreJSeEcL1UTme4qxWV1wzdYm RLRwY1M5lj6MnXqCaENjwmoVBOVUBHT8yNkX2WUUhjPMGOgU5xBkfpNwd6hthRyQPyxN hGCw== 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) Return-Path: 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: [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> X-Mailer: git-send-email 2.17.1 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 -- 2.17.1