diff mbox

[v2] x86emul/test: generate non-pie executable for 64bit builds

Message ID 20170925134057.30492-1-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Sept. 25, 2017, 1:40 p.m. UTC
PIE may (and commonly will) result in the binary being loaded above
the 4Gb boundary, which can't work with at least the VZEROUPPER compat
mode test.

Add -no-pie when appropriate so that linker won't generate a PIE
executable.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>

With this patch, vzeroupper passes, but one other test fails.
Testing SSE packed single 64-bit code sequence...[line 368] failed!
---
 tools/tests/x86_emulator/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Jan Beulich Sept. 25, 2017, 1:58 p.m. UTC | #1
>>> On 25.09.17 at 15:40, <wei.liu2@citrix.com> wrote:
> --- a/tools/tests/x86_emulator/Makefile
> +++ b/tools/tests/x86_emulator/Makefile
> @@ -76,7 +76,7 @@ $(addsuffix .c,$(SIMD)) $(addsuffix -avx.c,$(filter sse%,$(SIMD))):
>  	ln -sf simd.c $@
>  
>  $(TARGET): x86_emulate.o test_x86_emulator.o
> -	$(HOSTCC) -o $@ $^
> +	$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
>  
>  .PHONY: clean
>  clean:
> @@ -98,7 +98,9 @@ asm:
>  
>  asm/%: asm ;
>  
> -HOSTCFLAGS += $(CFLAGS_xeninclude) -I.
> +HOSTCFLAGS-x86_64 :=
> +$(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
> +HOSTCFLAGS += $(CFLAGS_xeninclude) -I. $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))

Hmm, so other than one could imply from gcc doc we get away
without using -fno-PIE at all, i.e. it's only an issue with how
linking is being done? Wouldn't it be better then to pass both (as
long as supported, if we really care about older compilers here)?

Jan
diff mbox

Patch

diff --git a/tools/tests/x86_emulator/Makefile b/tools/tests/x86_emulator/Makefile
index fd13ab53b1..87064494d1 100644
--- a/tools/tests/x86_emulator/Makefile
+++ b/tools/tests/x86_emulator/Makefile
@@ -76,7 +76,7 @@  $(addsuffix .c,$(SIMD)) $(addsuffix -avx.c,$(filter sse%,$(SIMD))):
 	ln -sf simd.c $@
 
 $(TARGET): x86_emulate.o test_x86_emulator.o
-	$(HOSTCC) -o $@ $^
+	$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
 
 .PHONY: clean
 clean:
@@ -98,7 +98,9 @@  asm:
 
 asm/%: asm ;
 
-HOSTCFLAGS += $(CFLAGS_xeninclude) -I.
+HOSTCFLAGS-x86_64 :=
+$(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
+HOSTCFLAGS += $(CFLAGS_xeninclude) -I. $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))
 
 x86.h := asm/x86-vendors.h asm/x86-defns.h asm/msr-index.h
 x86_emulate.h := x86_emulate.h x86_emulate/x86_emulate.h $(x86.h)