[RFC PATCH] ld: Nullify GCC default PIE in all linker tests
Alan Modra
amodra@gmail.com
Thu Mar 27 21:59:43 GMT 2025
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.
--
Alan Modra
More information about the Binutils
mailing list