[RFC PATCH] ld: Nullify GCC default PIE in all linker tests
Jens Remus
jremus@linux.ibm.com
Fri Mar 28 14:37:49 GMT 2025
Hello Alan,
thank you for your feedback!
On 27.03.2025 22:59, Alan Modra wrote:
> On Fri, Mar 21, 2025 at 06:01:17PM +0100, Jens Remus wrote:
>> Some distributions configure GCC with --enable-default-pie. This causes
>> compiles to default to -fPIE and links to default to -pie, unless other
>> options are explicitly given. As a consequence several linker tests
>> are compiled and linked in unexpected ways and may even unexpectedly fail
>> or pass.
>>
>> Test whether GCC is configured with --default-pie. Unconditionally
>> prepend $NOPIE_CFLAGS to the compile flags and $NOPIE_LDFLAGS to the
>> link flags for all linker tests to nullify GCC configured with default
>> PIE. These are then overridden by any deviating compiler flags
>> (e.g. -fPIC or -fPIE) and linker flags (e.g -pie or -shared) explicitly
>> specified by the tests.
>
> Yes, this would make writing some linker tests easier, but it also
> might mean fewer linker code paths are tested. So I'm inclined to say
> that individual tests should be changed as necessary rather than a
> global cflags change.
I understand that there is a value in reviewing linker tests that fail
when run with a compiler that defaults to PIE. After all it may be
valid to run the test in that flavor and something needs to be fixed.
But it also bears the risk of erroneously hiding linker test fails when
run with a compiler that defaults to PIE, as tests do not get run in
their intended way. It took me a while to figure out that for s390x it
makes a difference whether I run Binutils tests on a distribution that
has GCC configured to defaults to PIE or not.
Would it therefore be an option to make this somehow configurable as
opt-in to nullify default PIE? It would be easy via a RUNTESTFLAG
or ~/.dejagnurc setting. See my RFC v2 I just sent.
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
More information about the Binutils
mailing list