]> xenbits.xensource.com Git - xen.git/commitdiff
x86emul: place test blobs in executable section
authorJan Beulich <jbeulich@suse.com>
Thu, 15 Mar 2018 16:01:33 +0000 (17:01 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 15 Mar 2018 16:01:33 +0000 (17:01 +0100)
This allows the section contents to be disassembled without going
through any extra hoops, simplifying the analysis of problems in test
and/or emulation code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/tests/x86_emulator/Makefile
tools/tests/x86_emulator/test_x86_emulator.c

index c155f1217ba760de3283df0915a45f73e1367f28..417d5c0941696c74890dc7038862100086a2cec7 100644 (file)
@@ -91,7 +91,8 @@ $(addsuffix .h,$(TESTCASES)): %.h: %.c testcase.mk Makefile
                $(MAKE) -f testcase.mk TESTCASE=$* XEN_TARGET_ARCH=$(arch) $*-cflags="$$cflags" all; \
                prefix=$(shell echo $(subst -,_,$*) | sed -e 's,^\([0-9]\),_\1,'); \
                flavor=$$(echo $${cflags} | sed -e 's, .*,,' -e 'y,-=,__,') ; \
-               (echo "static const unsigned int $${prefix}_$(arch)$${flavor}[] = {"; \
+               (echo 'static const unsigned int __attribute__((section(".test, \"ax\", @progbits #")))' \
+                     "$${prefix}_$(arch)$${flavor}[] = {"; \
                 od -v -t x $*.bin | sed -e 's/^[0-9]* /0x/' -e 's/ /, 0x/g' -e 's/$$/,/'; \
                 echo "};") >>$@.new; \
                rm -f $*.bin; \
index 7291a29fead9d20a6ef239217ac6bdfc1982f715..029a38d7fbc7bc222515bc5457ba94a1591743e0 100644 (file)
@@ -4,6 +4,9 @@
 #include <sys/mman.h>
 
 #include "x86-emulate.h"
+
+asm ( ".pushsection .test, \"ax\", @progbits; .popsection" );
+
 #include "blowfish.h"
 #include "3dnow.h"
 #include "sse.h"
@@ -1142,9 +1145,9 @@ int main(int argc, char **argv)
 
 #define decl_insn(which) extern const unsigned char which[], \
                          which##_end[] asm ( ".L" #which "_end" )
-#define put_insn(which, insn) ".pushsection .test, \"ax\", @progbits\n" \
-                              #which ": " insn "\n"                     \
-                              ".L" #which "_end:\n"                     \
+#define put_insn(which, insn) ".pushsection .test\n" \
+                              #which ": " insn "\n"  \
+                              ".L" #which "_end:\n"  \
                               ".popsection"
 #define set_insn(which) (regs.eip = (unsigned long)(which))
 #define valid_eip(which) (regs.eip >= (unsigned long)(which) && \