]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
x86 and amd64 tests: Use .text and .previous around all top-level asm.
authorMark Wielaard <mark@klomp.org>
Sat, 25 Jan 2020 17:34:58 +0000 (18:34 +0100)
committerMark Wielaard <mark@klomp.org>
Sat, 25 Jan 2020 17:34:58 +0000 (18:34 +0100)
GCC10 defaults to -fno-common which exposes some latent bugs in
some of the top-level asm code in various .c test files. Some of the
tests started to segfault (even if not run under valgrind). Such code
needs to be wrapped inside a .text and a .previous asm statement to
make sure the code is generated in the .text code section and to
make sure the compiler doesn't lose track of the section currently
being used to generate data or code in. Without it code might be
generated inside a data section or the other way around.

12 files changed:
memcheck/tests/amd64/shr_edx.c
none/tests/amd64/fxtract.c
none/tests/amd64/jrcxz.c
none/tests/amd64/looper.c
none/tests/amd64/sbbmisc.c
none/tests/amd64/shrld.c
none/tests/amd64/slahf-amd64.c
none/tests/x86/cmpxchg8b.c
none/tests/x86/fxtract.c
none/tests/x86/lahf.c
none/tests/x86/looper.c
none/tests/x86/sbbmisc.c

index f8746afff52d1e0297ce667a13e993a30fb91adb..bed289471689d96f1a1b0f5cd62385b8565ea8b8 100644 (file)
@@ -8,6 +8,7 @@ ULong result;
 
 extern void shrl32_with_0x10 ( void );
 asm("\n"
+".text\n"
 "shrl32_with_0x10:\n"
 "\tpushq %rdx\n"
 "\tmovq data, %rdx\n"
@@ -20,6 +21,7 @@ asm("\n"
 "\tshrl32_with_0x10_jump:\n"
 "\tmov $0xdeaddead, %edx\n"
 "\tjmp shrl32_with_0x10_cont\n"
+".previous\n"
 );
 
 
index 4dff2a1f93c152301209c446d67c4ad74dc020c0..f4dfd36dfd035f60c58def857d2274a091205c56 100644 (file)
@@ -6,6 +6,7 @@ double arg, res1, res2;
 
 extern void do_fxtract ( void );
 asm("\n"
+".text\n"
 ".global do_fxtract\n"
 "do_fxtract:\n"
 "\tfinit\n"
@@ -13,7 +14,8 @@ asm("\n"
 "\tfxtract\n"
 "\tfstpl res1\n"
 "\tfstpl res2\n"
-"\tret"
+"\tret\n"
+".previous\n"
 );
 
 void try ( double x )
index dad088f0892dbf3fe1e496164d5f7e2bd04e7f5f..4d70734c25acd53b53ec6d9f30bc510e987a7fa1 100644 (file)
@@ -8,6 +8,7 @@ ULong arg64, res64;
 
 extern void foo64 ( void );
 asm("\n"
+".text\n"
 "foo64:\n"
 "\tpushq %rcx\n"
 
@@ -25,6 +26,7 @@ asm("\n"
 
 "\tpopq %rcx\n"
 "\tret\n"
+".previous\n"
 );
 
 
@@ -32,6 +34,7 @@ UInt arg32, res32;
 
 extern void foo32 ( void );
 asm("\n"
+".text\n"
 "foo32:\n"
 "\tpushq %rcx\n"
 
@@ -49,6 +52,7 @@ asm("\n"
 
 "\tpopq %rcx\n"
 "\tret\n"
+".previous\n"
 );
 
 
index cb7f5cbea76b30d349f7b062f91e3dc7da5c0659..586464242839371a40e54ff419f4abd785e6d74e 100644 (file)
@@ -22,6 +22,7 @@ asm("\n"
 "\tmovq %rax, res\n"
 "\tpopq %rcx\n"
 "\tret\n"
+".previous\n"
 );
 
 extern void loop_ne ( void );
@@ -42,6 +43,7 @@ asm("\n"
 "\tmovq %rax, res\n"
 "\tpopq %rcx\n"
 "\tret\n"
+".previous\n"
 );
 
 extern void loop_e ( void );
@@ -66,6 +68,7 @@ asm("\n"
 "\tmovq %rax, res\n"
 "\tpopq %rcx\n"
 "\tret\n"
+".previous\n"
 );
 
 int main ( void )
index dd70efadc20de4be472287dfd05cf3b74b88434b..1024bfd579e4ebd38253878f1721b77d19dcaa95 100644 (file)
@@ -9,6 +9,7 @@ int in_l, out_l1, out_l2;
 
 extern void sbb_ib_al ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_ib_al) ":\n"
 
 #ifndef VGP_amd64_darwin
@@ -37,11 +38,13 @@ VG_SYM(sbb_ib_al) ":\n"
 #endif
 
 "\tretq\n"
+".previous\n"
 );
 
 
 extern void sbb_iw_ax ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_iw_ax) ":\n"
 
 #ifndef VGP_amd64_darwin
@@ -69,11 +72,13 @@ VG_SYM(sbb_iw_ax) ":\n"
 #endif
 
 "\tretq\n"
+".previous\n"
 );
 
 
 extern void sbb_il_eax ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_il_eax) ":\n"
 
 #ifndef VGP_amd64_darwin
@@ -101,11 +106,13 @@ VG_SYM(sbb_il_eax) ":\n"
 #endif
 
 "\tretq\n"
+".previous\n"
 );
 
 
 extern void sbb_eb_gb ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_eb_gb) ":\n"
 
 #ifndef VGP_amd64_darwin
@@ -135,11 +142,13 @@ VG_SYM(sbb_eb_gb) ":\n"
 #endif
 
 "\tretq\n"
+".previous\n"
 );
 
 
 extern void sbb_eb_gb_2 ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_eb_gb_2) ":\n"
 "\tpushq %rcx\n"
 
@@ -173,11 +182,13 @@ VG_SYM(sbb_eb_gb_2) ":\n"
 
 "\tpopq %rcx\n"
 "\tretq\n"
+".previous\n"
 );
 
 
 extern void adc_eb_gb ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_eb_gb) ":\n"
 
 #ifndef VGP_amd64_darwin
@@ -207,11 +218,13 @@ VG_SYM(adc_eb_gb) ":\n"
 #endif
 
 "\tretq\n"
+".previous\n"
 );
 
 
 extern void adc_eb_gb_2 ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_eb_gb_2) ":\n"
 "\tpushq %rcx\n"
 
@@ -245,10 +258,12 @@ VG_SYM(adc_eb_gb_2) ":\n"
 
 "\tpopq %rcx\n"
 "\tretq\n"
+".previous\n"
 );
 
 extern void adc_ib_al ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_ib_al) ":\n"
 
 #ifndef VGP_amd64_darwin
@@ -276,11 +291,13 @@ VG_SYM(adc_ib_al) ":\n"
 #endif
 
 "\tretq\n"
+".previous\n"
 );
 
 
 extern void adc_iw_ax ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_iw_ax) ":\n"
 
 #ifndef VGP_amd64_darwin
@@ -308,11 +325,13 @@ VG_SYM(adc_iw_ax) ":\n"
 #endif
 
 "\tretq\n"
+".previous\n"
 );
 
 
 extern void adc_il_eax ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_il_eax) ":\n"
 
 #ifndef VGP_amd64_darwin
@@ -340,6 +359,7 @@ VG_SYM(adc_il_eax) ":\n"
 #endif
 
 "\tretq\n"
+".previous\n"
 );
 
 
index ca9d699e2c677c043e8045eda76787b9a98ec1b9..d77cfbdc90d89e78d0d76652b234fb335a60a15e 100644 (file)
@@ -30,6 +30,7 @@ ULong flags_out;
 
 extern void shld64 ( void );
 asm("\n"
+".text\n"
 "shld64:\n"
 "\tpushq %rsi\n"
 "\tpushq %r11\n"
@@ -47,10 +48,12 @@ asm("\n"
 "\tpopq %r11\n"
 "\tpopq %rsi\n"
 "\tret\n"
+".previous\n"
 );
 
 extern void shld32 ( void );
 asm("\n"
+".text\n"
 "shld32:\n"
 "\tpushq %rsi\n"
 "\tpushq %r11\n"
@@ -68,10 +71,12 @@ asm("\n"
 "\tpopq %r11\n"
 "\tpopq %rsi\n"
 "\tret\n"
+".previous\n"
 );
 
 extern void shld16 ( void );
 asm("\n"
+".text\n"
 "shld16:\n"
 "\tpushq %rsi\n"
 "\tpushq %r11\n"
@@ -89,11 +94,13 @@ asm("\n"
 "\tpopq %r11\n"
 "\tpopq %rsi\n"
 "\tret\n"
+".previous\n"
 );
 
 
 extern void shrd64 ( void );
 asm("\n"
+".text\n"
 "shrd64:\n"
 "\tpushq %rsi\n"
 "\tpushq %r11\n"
@@ -111,10 +118,12 @@ asm("\n"
 "\tpopq %r11\n"
 "\tpopq %rsi\n"
 "\tret\n"
+".previous\n"
 );
 
 extern void shrd32 ( void );
 asm("\n"
+".text\n"
 "shrd32:\n"
 "\tpushq %rsi\n"
 "\tpushq %r11\n"
@@ -132,10 +141,12 @@ asm("\n"
 "\tpopq %r11\n"
 "\tpopq %rsi\n"
 "\tret\n"
+".previous\n"
 );
 
 extern void shrd16 ( void );
 asm("\n"
+".text\n"
 "shrd16:\n"
 "\tpushq %rsi\n"
 "\tpushq %r11\n"
@@ -153,6 +164,7 @@ asm("\n"
 "\tpopq %r11\n"
 "\tpopq %rsi\n"
 "\tret\n"
+".previous\n"
 );
 
 
index 31857ecbaef69a8024a8682820b5cad77d56829c..361b6791bb43b3611d53fbb9fa0ff19cf17a8509 100644 (file)
@@ -5,6 +5,7 @@ typedef unsigned long long int ULong;
 
 extern ULong lahf_1 ( void );
 asm("\n"
+".text\n"
 "lahf_1:\n"
 "\tpushq $0\n"
 "\tpopfq\n"
@@ -13,10 +14,12 @@ asm("\n"
 "\tsubq %rax, %rdx\n"
 "\t.byte 0x9F\n" /* lahf */
 "\tret\n"
+".previous\n"
 );
 
 extern ULong lahf_0 ( void );
 asm("\n"
+".text\n"
 "lahf_0:\n"
 "\tpushq $0\n"
 "\tpopfq\n"
@@ -25,16 +28,19 @@ asm("\n"
 "\tsubq %rax, %rdx\n"
 "\t.byte 0x9F\n" /* lahf */
 "\tret\n"
+".previous\n"
 );
 
 extern ULong sahf_then_lahf ( ULong );
 asm("\n"
+".text\n"
 "sahf_then_lahf:\n"
 "\tmovq %rdi, %rax\n"
 "\t.byte 0x9E\n" /* sahf */
 "\tmovabsq $0, %rax\n"
 "\t.byte 0x9F\n" /* lahf */
 "\tret\n"
+".previous\n"
 );
 
 int main ( void )
index 3588840a86c5eb6e6f965bba0190c541ab945b8f..9ca56afa66ef2a6b70151f4f4903e93b7437b63e 100644 (file)
@@ -14,6 +14,7 @@ UInt zout;
 
 extern void foo ( void );
 asm("\n"
+    ".text\n"
     VG_SYM(foo) ":\n"
     "\tpushl %eax\n"
     "\tpushl %ebx\n"
@@ -40,6 +41,7 @@ asm("\n"
     "\tpopl %ebx\n"
     "\tpopl %eax\n"
     "\tret\n"
+    ".previous\n"
     );
 
 int main ( void )
index 235cda72c4b6150821b642cbcd97dff46fede8f8..f8c9bc41a32bbc5ff60822dbb255e34d461891db 100644 (file)
@@ -6,13 +6,15 @@ double arg, res1, res2;
 
 extern void do_fxtract ( void );
 asm("\n"
+".text\n"
 VG_SYM(do_fxtract) ":\n"
 "\tfinit\n"
 "\tfldl " VG_SYM(arg) "\n"
 "\tfxtract\n"
 "\tfstpl " VG_SYM(res1) "\n"
 "\tfstpl " VG_SYM(res2) "\n"
-"\tret"
+"\tret\n"
+".previous\n"
 );
 
 void try ( double x )
index fc09352ac97bc39bb61e09548bd9e3a4db38a24e..a04c10da9f60e4e1b237cabf4b88cab2880f839f 100644 (file)
@@ -3,6 +3,7 @@
 
 extern int foo_1 ( void );
 asm("\n"
+".text\n"
 VG_SYM(foo_1) ":\n"
 "\tpushl $0\n"
 "\tpopfl\n"
@@ -11,10 +12,12 @@ VG_SYM(foo_1) ":\n"
 "\tsubl %eax, %edx\n"
 "\tlahf\n"
 "\tret\n"
+".previous\n"
 );
 
 extern int foo_0 ( void );
 asm("\n"
+".text\n"
 VG_SYM(foo_0) ":\n"
 "\tpushl $0\n"
 "\tpopfl\n"
@@ -23,6 +26,7 @@ VG_SYM(foo_0) ":\n"
 "\tsubl %eax, %edx\n"
 "\tlahf\n"
 "\tret\n"
+".previous\n"
 );
 
 int main ( void )
index 60554ec7637d68e405406ce11cb53e5f31696b90..7f7ace8ad8216a88abde33e11e88dbffcb9af9d1 100644 (file)
@@ -21,6 +21,7 @@ VG_SYM(loop_plain) ":\n"
 "\tmovl %eax, " VG_SYM(res) "\n"
 "\tpopl %ecx\n"
 "\tret\n"
+".previous\n"
 );
 
 extern void loop_ne ( void );
@@ -40,6 +41,7 @@ VG_SYM(loop_ne) ":\n"
 "\tmovl %eax, " VG_SYM(res) "\n"
 "\tpopl %ecx\n"
 "\tret\n"
+".previous\n"
 );
 
 extern void loop_e ( void );
@@ -63,6 +65,7 @@ VG_SYM(loop_e) ":\n"
 "\tmovl %eax, " VG_SYM(res) "\n"
 "\tpopl %ecx\n"
 "\tret\n"
+".previous\n"
 );
 
 int main ( void )
index 322d6e17d796c2bf641e04b97e721a180d168914..7c4585d95785f943921be72deb36b2b053fa028e 100644 (file)
@@ -9,6 +9,7 @@ int in_l, out_l1, out_l2;
 
 extern void sbb_ib_al ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_ib_al) ":\n"
 
 "\tmovb " VG_SYM(in_b) ", %al\n"
@@ -22,11 +23,13 @@ VG_SYM(sbb_ib_al) ":\n"
 "\tmovb %al, " VG_SYM(out_b2) "\n"
 
 "\tret\n"
+".previous\n"
 );
 
 
 extern void sbb_iw_ax ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_iw_ax) ":\n"
 
 "\tmovw " VG_SYM(in_w) ", %ax\n"
@@ -40,11 +43,13 @@ VG_SYM(sbb_iw_ax) ":\n"
 "\tmovw %ax, " VG_SYM(out_w2) "\n"
 
 "\tret\n"
+".previous\n"
 );
 
 
 extern void sbb_il_eax ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_il_eax) ":\n"
 
 "\tmovl " VG_SYM(in_l) ", %eax\n"
@@ -58,11 +63,13 @@ VG_SYM(sbb_il_eax) ":\n"
 "\tmovl %eax, " VG_SYM(out_l2) "\n"
 
 "\tret\n"
+".previous\n"
 );
 
 
 extern void sbb_eb_gb ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_eb_gb) ":\n"
 
 "\tmovb " VG_SYM(in_b) ", %al\n"
@@ -76,11 +83,13 @@ VG_SYM(sbb_eb_gb) ":\n"
 "\tmovb %al, " VG_SYM(out_b2) "\n"
 
 "\tret\n"
+".previous\n"
 );
 
 
 extern void sbb_eb_gb_2 ( void );
 asm("\n"
+".text\n"
 VG_SYM(sbb_eb_gb_2) ":\n"
 "\tpushl %ecx\n"
 
@@ -98,11 +107,13 @@ VG_SYM(sbb_eb_gb_2) ":\n"
 
 "\tpopl %ecx\n"
 "\tret\n"
+".previous\n"
 );
 
 
 extern void adc_eb_gb ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_eb_gb) ":\n"
 
 "\tmovb " VG_SYM(in_b) ", %al\n"
@@ -116,11 +127,13 @@ VG_SYM(adc_eb_gb) ":\n"
 "\tmovb %al, " VG_SYM(out_b2) "\n"
 
 "\tret\n"
+".previous\n"
 );
 
 
 extern void adc_eb_gb_2 ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_eb_gb_2) ":\n"
 "\tpushl %ecx\n"
 
@@ -138,10 +151,12 @@ VG_SYM(adc_eb_gb_2) ":\n"
 
 "\tpopl %ecx\n"
 "\tret\n"
+".previous\n"
 );
 
 extern void adc_ib_al ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_ib_al) ":\n"
 
 "\tmovb " VG_SYM(in_b) ", %al\n"
@@ -155,11 +170,13 @@ VG_SYM(adc_ib_al) ":\n"
 "\tmovb %al, " VG_SYM(out_b2) "\n"
 
 "\tret\n"
+".previous\n"
 );
 
 
 extern void adc_iw_ax ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_iw_ax) ":\n"
 
 "\tmovw " VG_SYM(in_w) ", %ax\n"
@@ -173,11 +190,13 @@ VG_SYM(adc_iw_ax) ":\n"
 "\tmovw %ax, " VG_SYM(out_w2) "\n"
 
 "\tret\n"
+".previous\n"
 );
 
 
 extern void adc_il_eax ( void );
 asm("\n"
+".text\n"
 VG_SYM(adc_il_eax) ":\n"
 
 "\tmovl " VG_SYM(in_l) ", %eax\n"
@@ -191,6 +210,7 @@ VG_SYM(adc_il_eax) ":\n"
 "\tmovl %eax, " VG_SYM(out_l2) "\n"
 
 "\tret\n"
+".previous\n"
 );