Skip to content
Snippets Groups Projects
Commit db882c5c authored by Jessica Clarke's avatar Jessica Clarke Committed by Michael Roth
Browse files

Partially revert "build: -no-pie is no functional linker flag"


This partially reverts commit bbd2d5a8.

This commit was misguided and broke using --disable-pie on any distro
that enables PIE by default in their compiler driver, including Debian
and its derivatives. Whilst -no-pie is not a linker flag, it is a
compiler driver flag that ensures -pie is not automatically passed by it
to the linker. Without it, all compile_prog checks will fail as any code
built with the explicit -fno-pie will fail to link with the implicit
default -pie due to trying to use position-dependent relocations. The
only bug that needed fixing was LDFLAGS_NOPIE being used as a flag for
the linker itself in pc-bios/optionrom/Makefile.

Note this does not reinstate exporting LDFLAGS_NOPIE, as it is unused,
since the only previous use was the one that should not have existed. I
have also updated the comment for the -fno-pie and -no-pie checks to
reflect what they're actually needed for.

Fixes: bbd2d5a8
Cc: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: default avatarJessica Clarke <jrtc27@jrtc27.com>
Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Signed-off-by: default avatarMichael Roth <michael.roth@amd.com>
parent 62a012b0
Branches
Tags
No related merge requests found
...@@ -2192,9 +2192,11 @@ static THREAD int tls_var; ...@@ -2192,9 +2192,11 @@ static THREAD int tls_var;
int main(void) { return tls_var; } int main(void) { return tls_var; }
EOF EOF
# Check we support --no-pie first; we will need this for building ROMs. # Check we support -fno-pie and -no-pie first; we will need the former for
# building ROMs, and both for everything if --disable-pie is passed.
if compile_prog "-Werror -fno-pie" "-no-pie"; then if compile_prog "-Werror -fno-pie" "-no-pie"; then
CFLAGS_NOPIE="-fno-pie" CFLAGS_NOPIE="-fno-pie"
LDFLAGS_NOPIE="-no-pie"
fi fi
if test "$static" = "yes"; then if test "$static" = "yes"; then
...@@ -2210,6 +2212,7 @@ if test "$static" = "yes"; then ...@@ -2210,6 +2212,7 @@ if test "$static" = "yes"; then
fi fi
elif test "$pie" = "no"; then elif test "$pie" = "no"; then
CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment