]> xenbits.xensource.com Git - xen.git/commitdiff
x86emul/test: don't use *_len symbols
authorJan Beulich <JBeulich@suse.com>
Tue, 24 Jan 2017 16:22:03 +0000 (16:22 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 15 May 2019 12:35:22 +0000 (13:35 +0100)
... as they don't work as intended with -fPIC.

I did prefer them over *_end ones at the time because older gcc would
cause .L* symbols to be public, due to issuing .globl for all
referenced externals. And labels at the end of instructions collide
with the ones at the start of the next instruction, making disassembly
harder to grok. Luckily recent gcc no longer issues those .globl
directives, and hence .L* labels, staying local by default, no longer
get in the way.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Wei Liu <wei.liu2@citrix.com>
(cherry picked from commit 9315fa0ef736d1153c98ce42bff5853da5ec697f)

tools/tests/x86_emulator/test_x86_emulator.c

index 7b467fe021592ecc08b4b3627962128c912678ab..29c6cf1ec24c6c3e8e8e68cd8c00f37b9106a701 100644 (file)
@@ -766,15 +766,16 @@ int main(int argc, char **argv)
         goto fail;
     printf("okay\n");
 
-#define decl_insn(which) extern const unsigned char which[], which##_len[]
+#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"                     \
-                              ".equ " #which "_len, .-" #which "\n"     \
+                              ".L" #which "_end:\n"                     \
                               ".popsection"
 #define set_insn(which) (regs.eip = (unsigned long)memcpy(instr, which, \
-                                             (unsigned long)which##_len))
+                          (unsigned long)which##_end - (unsigned long)(which)))
 #define check_eip(which) (regs.eip == (unsigned long)instr + \
-                                      (unsigned long)which##_len)
+                          (unsigned long)which##_end - (unsigned long)(which))
 
     printf("%-40s", "Testing movq %mm3,(%ecx)...");
     if ( stack_exec && cpu_has_mmx )