diff mbox

[for-4.8,v2] tools/tests/x86_emulator: Pass -no-pie -fno-pic to gcc on x86_32

Message ID 20161101180005.14897-1-ian.jackson@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Nov. 1, 2016, 6 p.m. UTC
The current build fails with GCC6 on Debian sid i386 (unstable):

 /tmp/ccqjaueF.s: Assembler messages:
 /tmp/ccqjaueF.s:3713: Error: missing or invalid displacement expression `vmovd_to_reg_len@GOT'

This is due to the combination of GCC6, and Debian's decision to
enable some hardening flags by default (to try to make runtime
addresses less predictable):
  https://wiki.debian.org/Hardening/PIEByDefaultTransition

This is of no benefit for the x86 instruction emulator test, which is
a rebuild of the emulator code for testing purposes only.  So pass
options to disable this.

These options will be no-ops if they are the same as the compiler
default.

On amd64, the -fno-pic breaks the build in a different way.  So do
this only on i386.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>

squash! tools/tests/x86_emulator: Pass -no-pie -fno-pic to gcc

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
---
 tools/tests/x86_emulator/Makefile | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jan Beulich Nov. 2, 2016, 9:02 a.m. UTC | #1
>>> On 01.11.16 at 19:00, <ian.jackson@citrix.com> wrote:
> --- a/tools/tests/x86_emulator/Makefile
> +++ b/tools/tests/x86_emulator/Makefile
> @@ -45,6 +45,10 @@ x86_emulate/x86_emulate.c x86_emulate/x86_emulate.h:
>  
>  HOSTCFLAGS += $(CFLAGS_xeninclude)
>  
> +ifeq ($(XEN_TARGET_ARCH),x86_32)
> +HOSTCFLAGS += -no-pie -fno-pic
> +endif

I've quickly tried with gcc 4.3.4, and that one doesn't appear to know
of -no-pie. And then I went through some older gcc builds I still have
around, and to my surprise even 5.x doesn't seem to know of the
option yet (i.e. only 6.x really does).

Jan
diff mbox

Patch

diff --git a/tools/tests/x86_emulator/Makefile b/tools/tests/x86_emulator/Makefile
index 13ace9a..d349c0f 100644
--- a/tools/tests/x86_emulator/Makefile
+++ b/tools/tests/x86_emulator/Makefile
@@ -45,6 +45,10 @@  x86_emulate/x86_emulate.c x86_emulate/x86_emulate.h:
 
 HOSTCFLAGS += $(CFLAGS_xeninclude)
 
+ifeq ($(XEN_TARGET_ARCH),x86_32)
+HOSTCFLAGS += -no-pie -fno-pic
+endif
+
 x86_emulate.o: x86_emulate.c x86_emulate/x86_emulate.c x86_emulate/x86_emulate.h
 	$(HOSTCC) $(HOSTCFLAGS) -c -g -o $@ $<