Mark Wielaard 6ff5b8
commit 022f5af61bc3cbfa2b74ab355b0d2d30b3dab027
Mark Wielaard 6ff5b8
Author: Khem Raj <raj.khem@gmail.com>
Mark Wielaard 6ff5b8
Date:   Sat Dec 22 15:28:40 2018 -0800
Mark Wielaard 6ff5b8
Mark Wielaard 6ff5b8
    tests/amd64: Do not clobber %rsp register
Mark Wielaard 6ff5b8
    
Mark Wielaard 6ff5b8
    This is seen with gcc-9.0 compiler now which is fix that gcc community
Mark Wielaard 6ff5b8
    did recently
Mark Wielaard 6ff5b8
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52813
Mark Wielaard 6ff5b8
    
Mark Wielaard 6ff5b8
    Signed-off-by: Khem Raj <raj.khem@gmail.com>
Mark Wielaard 6ff5b8
Mark Wielaard 6ff5b8
diff --git a/none/tests/amd64-linux/bug345887.c b/none/tests/amd64-linux/bug345887.c
Mark Wielaard 6ff5b8
index 0f9237d..269bd70 100644
Mark Wielaard 6ff5b8
--- a/none/tests/amd64-linux/bug345887.c
Mark Wielaard 6ff5b8
+++ b/none/tests/amd64-linux/bug345887.c
Mark Wielaard 6ff5b8
@@ -20,13 +20,17 @@ static void inner(void)
Mark Wielaard 6ff5b8
       "movq $0x10d, %%r14\n"
Mark Wielaard 6ff5b8
       "movq $0x10e, %%r15\n"
Mark Wielaard 6ff5b8
       // not %rbp as mdb is then not able to reconstruct stack trace
Mark Wielaard 6ff5b8
+      // Do change %rsp (to test a bogus stack pointer),
Mark Wielaard 6ff5b8
+      // but don't add %rsp to the clobber list since gcc ignores it
Mark Wielaard 6ff5b8
+      // and since gcc >= 9.0 errors about it
Mark Wielaard 6ff5b8
+      // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52813
Mark Wielaard 6ff5b8
       "movq $0x10f, %%rsp\n"
Mark Wielaard 6ff5b8
       "movq $0x1234, (%%rax)\n"  // should cause SEGV here
Mark Wielaard 6ff5b8
       "ud2"                      // should never get here
Mark Wielaard 6ff5b8
       : // no output registers
Mark Wielaard 6ff5b8
       : // no input registers
Mark Wielaard 6ff5b8
       : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi",
Mark Wielaard 6ff5b8
-        "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "%rsp");
Mark Wielaard 6ff5b8
+        "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15");
Mark Wielaard 6ff5b8
 }
Mark Wielaard 6ff5b8
 
Mark Wielaard 6ff5b8
 __attribute__((noinline))
Mark Wielaard 607b6f
commit c512949082c4fc2285a82e102d4212c66e034a31
Mark Wielaard 607b6f
Author: Mark Wielaard <mark@klomp.org>
Mark Wielaard 607b6f
Date:   Fri Jan 11 20:00:17 2019 +0100
Mark Wielaard 607b6f
Mark Wielaard 607b6f
    Bug 402480 Do not use %esp in clobber list.
Mark Wielaard 607b6f
    
Mark Wielaard 607b6f
    This is the same fix as for amd64-linux, but now for x86-linux.
Mark Wielaard 607b6f
Mark Wielaard 607b6f
diff --git a/none/tests/x86-linux/bug345887.c b/none/tests/x86-linux/bug345887.c
Mark Wielaard 607b6f
index f2e8a8d..ef21d4e 100644
Mark Wielaard 607b6f
--- a/none/tests/x86-linux/bug345887.c
Mark Wielaard 607b6f
+++ b/none/tests/x86-linux/bug345887.c
Mark Wielaard 607b6f
@@ -12,12 +12,14 @@ static void inner(void)
Mark Wielaard 607b6f
       "movl $0x105, %%esi\n"
Mark Wielaard 607b6f
       "movl $0x106, %%edi\n"
Mark Wielaard 607b6f
       // not %ebp as mdb is then not able to reconstruct stack trace
Mark Wielaard 607b6f
+      // clobbering %esp is really bad, but that is kind of the point
Mark Wielaard 607b6f
+      // we don't add it to the clobber list since gcc9 warns about that
Mark Wielaard 607b6f
       "movl $0x108, %%esp\n"
Mark Wielaard 607b6f
       "movl $0x1234, (%%eax)\n"  // should cause SEGV here
Mark Wielaard 607b6f
       "ud2"                      // should never get here
Mark Wielaard 607b6f
       : // no output registers
Mark Wielaard 607b6f
       : // no input registers
Mark Wielaard 607b6f
-      : "memory", "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "%esp");
Mark Wielaard 607b6f
+      : "memory", "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
Mark Wielaard 607b6f
 }
Mark Wielaard 607b6f
 
Mark Wielaard 607b6f
 __attribute__((noinline))