Skip to contentSkip to conversation

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

PATCH In review Wei Liu 2 participants 5 messages Sep 25, 2017

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH v2 1/1 x86emul/test: generate non-pie executable for 64bit builds

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.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

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(-)
tools/tests/x86_emulator/Makefile +4 -2
index fd13ab53b1..87064494d1 100644
@@ -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)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 25.09.17 at 15:40, <[email protected]> wrote:
tools/tests/x86_emulator/Makefile +1 -1
@@ -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:

tools/tests/x86_emulator/Makefile asm: · line 103

Quoted 7 lines
tools/tests/x86_emulator/Makefile +3 -1
@@ -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

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#2 lore raw
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 25.09.17 at 15:40, <[email protected]> wrote:
tools/tests/x86_emulator/Makefile +1 -1
@@ -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 ;
 
Quoted 8 lines

tools/tests/x86_emulator/Makefile asm: · line 103

Quoted 4 lines
tools/tests/x86_emulator/Makefile +3 -1
-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?

Yeah, it was ld that complained.

Quoted 2 lines

Wouldn't it be better then to pass both (as
long as supported, if we really care about older compilers here)?

I'm fine with that. -fno-PIE is supported a long time ago. I can fold in the following diff to this patch.

(quoted diff) +0 -0

b/tools/tests/x86_emulator/Makefile
index 87064494d1..fbe02cd2f9 100644

tools/tests/x86_emulator/Makefile +1 -1
@@ -98,7 +98,7 @@ asm:
 
 asm/%: asm ;
 
-HOSTCFLAGS-x86_64 :=
+HOSTCFLAGS-x86_64 := -fno-PIE
 $(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
 HOSTCFLAGS += $(CFLAGS_xeninclude) -I.  $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))
 

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 25.09.17 at 16:11, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich

Wouldn't it be better then to pass both (as
long as supported, if we really care about older compilers here)?

I'm fine with that. -fno-PIE is supported a long time ago. I can fold in the following diff to this patch.

tools/tests/x86_emulator/Makefile +0 -0
index 87064494d1..fbe02cd2f9 100644

tools/tests/x86_emulator/Makefile asm: · line 103

Quoted 7 lines
tools/tests/x86_emulator/Makefile +1 -1
@@ -98,7 +98,7 @@ asm:
 
 asm/%: asm ;
 
-HOSTCFLAGS-x86_64 :=
+HOSTCFLAGS-x86_64 := -fno-PIE
 $(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
 HOSTCFLAGS += $(CFLAGS_xeninclude) -I.  $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))

Feel free to commit with that addition (or tell me that I should), or maybe Andrew could give his ack.

Thanks for your help here, Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#4 lore raw
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 25.09.17 at 16:11, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich

Wouldn't it be better then to pass both (as
long as supported, if we really care about older compilers here)?

I'm fine with that. -fno-PIE is supported a long time ago. I can fold in the following diff to this patch.

tools/tests/x86_emulator/Makefile +0 -0
index 87064494d1..fbe02cd2f9 100644
@@ -98,7 +98,7 @@ asm:
 
 asm/%: asm ;
 
Quoted 8 lines

tools/tests/x86_emulator/Makefile asm: · line 103

Quoted 4 lines
tools/tests/x86_emulator/Makefile +1 -1
-HOSTCFLAGS-x86_64 :=
+HOSTCFLAGS-x86_64 := -fno-PIE
 $(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
 HOSTCFLAGS += $(CFLAGS_xeninclude) -I.  $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))

Feel free to commit with that addition (or tell me that I should), or maybe Andrew could give his ack.

I will commit it soon. I will add your ack too.

Quoted 2 lines

Thanks for your help here, Jan

You're welcome.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel