]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Regtest: fox for new none x86 bug520856-x86 test users/paulf/try-fix_x86_ind_jmp_cs_prefix
authorPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 1 Jun 2026 10:48:14 +0000 (12:48 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 1 Jun 2026 10:48:14 +0000 (12:48 +0200)
A problem with the jumped to skip address with some versions of GCC.
Fix it by junping in the inline assembler.

none/tests/x86/Makefile.am
none/tests/x86/bug520856-x86.c
none/tests/x86/bug520856-x86.stdout.exp [new file with mode: 0644]

index ff42aecbfdc0b53ff33158bd620ce40abb209eb0..bc7d72c96ac6647f189d5314cfda0096750e2efd 100644 (file)
@@ -46,7 +46,7 @@ EXTRA_DIST = \
        bug135421-x86.stderr.exp bug135421-x86.stdout.exp bug135421-x86.vgtest \
        bug137714-x86.stdout.exp bug137714-x86.vgtest \
        bug152818-x86.stderr.exp bug152818-x86.stdout.exp bug152818-x86.vgtest \
-       bug520856-x86.vgtest \
+       bug520856-x86.vgtest bug520856-x86.stdout.exp \
        cet_nops.stdout.exp cet_nops.vgtest \
        cmpxchg8b.stderr.exp cmpxchg8b.stdout.exp cmpxchg8b.vgtest \
        cpuid.stderr.exp cpuid.stdout.exp cpuid.vgtest \
index 6212d1a2bb8b0b24e94e06f3d42e1785049777e7..5cc04ea56195a8605f82119c99b3b44cc605b98d 100644 (file)
@@ -1,27 +1,26 @@
-/* test_cs_jmp.c - regression test for CS-prefixed indirect jmp */
+/* Test for CS-prefixed indirect jmp.
+ * The previous version had a problem loading the skip address on illumos
+ * This version uses all inline asm and jumps around an int 3 to avoid
+ * crashing with SIGTRAP. Prints "ok" on success.
+*/
 #include <stdio.h>
 
 static void test(void)
 {
-   /* A CS-prefixed indirect jmp through a register is simpler:
-      2E FF E0 = cs jmp *%eax
-      This uses the same 0x2E/0xFF path without a complex SIB byte */
-   int dummy = (int)&&skip;
    __asm__ volatile (
-       "movl %0, %%eax\n\t"
-       ".byte 0x2E, 0xFF, 0xE0\n\t"   /* cs jmp *%eax */
-       :
-       : "r"(dummy)
-       : "eax"
+      "leal 1f, %%eax\n\t"
+      ".byte 0x2E, 0xFF, 0xE0\n\t"
+      ".int 3\n\t"
+      "1:\n\t"
+      :
+      :
+      : "eax"
    );
-   // should skip this
-   printf("failed\n");
-skip:
-   return;
 }
 
 int main(void)
 {
     test();
+    printf("ok\n");
     return 0;
 }
diff --git a/none/tests/x86/bug520856-x86.stdout.exp b/none/tests/x86/bug520856-x86.stdout.exp
new file mode 100644 (file)
index 0000000..9766475
--- /dev/null
@@ -0,0 +1 @@
+ok