]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD and Darwin: clean up fake sigreturn syscall numbers
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 7 Dec 2025 20:59:40 +0000 (21:59 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 7 Dec 2025 21:07:19 +0000 (22:07 +0100)
Firstly make them a bit more similar. Secondly, switch Darwin
from using __NR_MAXSYSCALL which changes with every Darwin version
to using 1000 like FreeBSD.

Change NEWS for macOS 10.13, it has now progressed beyond
'preliminary'.

NEWS
coregrind/m_signals.c
coregrind/m_syswrap/priv_syswrap-darwin.h
coregrind/m_syswrap/syswrap-darwin.c
coregrind/m_syswrap/syswrap-freebsd.c
coregrind/m_trampoline.S
include/vki/vki-scnums-darwin.h
include/vki/vki-scnums-freebsd.h

diff --git a/NEWS b/NEWS
index 0731634f8c7ef7faebacebcfe77ca5cd95095c3d..0702dbc94f05a5283cdf0469481b76a00b4ecc15 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,9 +4,9 @@ Release 3.27.0 (?? Apr 2025)
 This release supports X86/Linux, AMD64/Linux, ARM32/Linux, ARM64/Linux,
 PPC32/Linux, PPC64BE/Linux, PPC64LE/Linux, S390X/Linux, MIPS32/Linux,
 MIPS64/Linux, RISCV64/Linux, ARM/Android, ARM64/Android, MIPS32/Android,
-X86/Android, X86/Solaris, AMD64/Solaris, AMD64/MacOSX 10.12, X86/FreeBSD,
-AMD64/FreeBSD and ARM64/FreeBSD There is also preliminary support for
-X86/macOS 10.13, AMD64/macOS 10.13 and nanoMIPS/Linux.
+X86/Android, X86/Solaris, AMD64/Solaris, X86/macOS, AMD64/macOS. 
+X86/FreeBSD, AMD64/FreeBSD and ARM64/FreeBSD. There is preliminary support
+for nanoMIPS/Linux. macOS is supported up to version 10.13 High Sierra.
 
 * ==================== CORE CHANGES ===================
 
index a914cd0c28c0303d7b0ff84ae2c5e89d2c26ebc1..1b0200287c819c3a395fea6307c6a73bb0064a08 100644 (file)
@@ -1041,7 +1041,7 @@ extern void my_sigreturn(void);
    ".text\n" \
    ".globl my_sigreturn\n" \
    "my_sigreturn:\n" \
-   "    movl $" VG_STRINGIFY(__NR_DARWIN_FAKE_SIGRETURN) ",%eax\n" \
+   "    movl $" VG_STRINGIFY(__NR_darwin_fake_sigreturn) ",%eax\n" \
    "    int $0x80\n"
 
 #elif defined(VGP_amd64_darwin)
@@ -1049,7 +1049,7 @@ extern void my_sigreturn(void);
    ".text\n" \
    ".globl my_sigreturn\n" \
    "my_sigreturn:\n" \
-   "    movq $" VG_STRINGIFY(__NR_DARWIN_FAKE_SIGRETURN) ",%rax\n" \
+   "    movq $" VG_STRINGIFY(__NR_darwin_fake_sigreturn) ",%rax\n" \
    "    syscall\n"
 
 #elif defined(VGP_s390x_linux)
index d3fd32458c81427d57f3b678e8cd6b6d0c623483..579b3d8c6f803a8305de5366465bc9e49bdf8c4e 100644 (file)
@@ -240,7 +240,7 @@ DECL_TEMPLATE(darwin, kdebug_trace);            // 180
 DECL_TEMPLATE(darwin, setegid);                 // 182
 DECL_TEMPLATE(darwin, seteuid);                 // 183
 DECL_TEMPLATE(darwin, sigreturn);               // 184
-DECL_TEMPLATE(darwin, FAKE_SIGRETURN);
+DECL_TEMPLATE(darwin, fake_sigreturn);          // 1000
 // NYI chud 185
 #if DARWIN_VERS >= DARWIN_10_13
 // NYI thread_selfcounts                        // 186
index 67fdd9e2678815b74cb96f43375add6fef8092fb..0113d388dee46f39252d2a5b415e816ef9c26dc6 100644 (file)
@@ -9358,7 +9358,7 @@ PRE(swtch_pri)
 }
 
 
-PRE(FAKE_SIGRETURN)
+PRE(fake_sigreturn)
 {
    /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for
       an explanation of what follows. */
@@ -9366,7 +9366,7 @@ PRE(FAKE_SIGRETURN)
       sigframe-x86-darwin.c. */
    /* See also comments just below on PRE(sigreturn). */
 
-   PRINT("FAKE_SIGRETURN ( )");
+   PRINT("fake_sigreturn ( )");
 
    vg_assert(VG_(is_valid_tid)(tid));
    vg_assert(tid >= 1 && tid < VG_N_THREADS);
@@ -9430,10 +9430,10 @@ PRE(sigreturn)
       1. Change the second argument of VG_(sigframe_destroy) from
          "Bool isRT" to "UInt sysno", so we can pass the syscall
          number, so it can distinguish this case from the
-         __NR_DARWIN_FAKE_SIGRETURN case.
+         __NR_darwin_fake_sigreturn case.
 
       2. In VG_(sigframe_destroy), look at sysno to distinguish the
-         cases.  For __NR_DARWIN_FAKE_SIGRETURN, behave as at present.
+         cases.  For __NR_darwin_fake_sigreturn, behave as at present.
          For this case, restore the thread's CPU state (or at least
          the integer regs) from the ucontext in ARG1 (and do all the
          other "signal-returns" stuff too).
@@ -11542,8 +11542,8 @@ const SyscallTableEntry ML_(syscall_table)[] = {
 // _____(__NR_ntp_gettime),                             // 528
 // _____(__NR_os_fault_with_payload),                   // 529
 #endif
-// _____(__NR_MAXSYSCALL)
-   MACX_(__NR_DARWIN_FAKE_SIGRETURN, FAKE_SIGRETURN)
+
+   MACX_(__NR_darwin_fake_sigreturn, fake_sigreturn)
 };
 
 
index c2fd35d2b1b832e14eebd69e7837937559bc5932..e1c1dcc14ea0d6731732b0bfb63907226693f12c 100644 (file)
@@ -7941,7 +7941,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
     BSDX_(__NR_jail_attach_jd,  sys_jail_attach_jd),    // 597
     BSDX_(__NR_jail_remove_jd,  sys_jail_remove_jd),    // 598
 
-   BSDX_(__NR_fake_sigreturn,   sys_fake_sigreturn),    // 1000, fake sigreturn
+   BSDX_(__NR_freebsd_fake_sigreturn,   sys_fake_sigreturn), // 1000, fake sigreturn
 
 };
 
index 0746fd0f18fb44f6d0dd66b8ba6fe53b70ad82c3..6ba42613e9a0c6402ddc0ab9c2fdc17f1687bb82 100644 (file)
@@ -960,7 +960,7 @@ VG_(x86_freebsd_SUBST_FOR_sigreturn):
        pushl   %eax
        pushl   %eax                    /* fake return addr */
 /*     movl    0x44(%eax), %gs ; restore %gs, not done by sigreturn */
-        movl    $__NR_fake_sigreturn, %eax
+        movl    $__NR_freebsd_fake_sigreturn, %eax
         int     $0x80
         ud2
 
@@ -987,7 +987,7 @@ VG_(amd64_freebsd_SUBST_FOR_sigreturn):
         /* This is a very specific sequence which GDB uses to
            recognize signal handler frames. */
 
-        movq    $__NR_fake_sigreturn, %rax
+        movq    $__NR_freebsd_fake_sigreturn, %rax
 
         /* running the preprocessor on
          * src/amd64.amd64/lib/libc/sigreturn.S
@@ -1046,7 +1046,7 @@ VG_(trampoline_stuff_start):
 .global VG_(arm64_freebsd_SUBST_FOR_sigreturn)
 .type   VG_(arm64_freebsd_SUBST_FOR_sigreturn),#function
 VG_(arm64_freebsd_SUBST_FOR_sigreturn):
-       mov x8, # __NR_fake_sigreturn
+       mov x8, # __NR_freebsd_fake_sigreturn
         mov x0, sp
         svc #0
         .long 0xFFFFFFFF /*illegal insn*/
@@ -1082,7 +1082,7 @@ VG_(trampoline_stuff_start):
 VG_(x86_darwin_SUBST_FOR_sigreturn):
         /* XXX does this need to have any special form? (cf x86-linux
        version) */
-        movl    $ __NR_DARWIN_FAKE_SIGRETURN, %eax
+        movl    $ __NR_darwin_fake_sigreturn, %eax
         int     $0x80
         ud2
 
@@ -1242,7 +1242,7 @@ VG_(trampoline_stuff_start):
 VG_(amd64_darwin_SUBST_FOR_sigreturn):
         /* XXX does this need to have any special form? (cf x86-linux
        version) */
-        movq    $ __NR_DARWIN_FAKE_SIGRETURN, %rax
+        movq    $ __NR_darwin_fake_sigreturn, %rax
         syscall
         ud2
 
index ae1618b52bcac211a3964a3342a1eb62336edbf8..9e5c8696456792b599386343ef687937b4dda524 100644 (file)
 #define        __NR_os_fault_with_payload  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(529)
 #endif /* DARWIN_VERS >= DARWIN_10_13 */
 
-#if DARWIN_VERS < DARWIN_10_6
-#define        __NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(427)
-#elif DARWIN_VERS < DARWIN_10_7
-#define        __NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(430)
-#elif DARWIN_VERS < DARWIN_10_9
-#define        __NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(430)
-#elif DARWIN_VERS == DARWIN_10_9
-#define        __NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(456)
-#elif DARWIN_VERS == DARWIN_10_10
-#define __NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(490)
-#elif DARWIN_VERS == DARWIN_10_11
-#define __NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(500)
-#elif DARWIN_VERS == DARWIN_10_12
-#define __NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(522)
-#elif DARWIN_VERS == DARWIN_10_13
-#define __NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(530)
-#else
-#error unknown darwin version
-#endif
-
-#define __NR_DARWIN_FAKE_SIGRETURN (1 + __NR_MAXSYSCALL)
+#define __NR_darwin_fake_sigreturn  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(1000)
 
 #endif
index 83e4430c2004d9a73fb44b714689575dc5a45cb7..bb6d485b25cf20447f1694cf200ebcad04ac3ccf 100644 (file)
 #define __NR_jail_attach_jd      597
 #define __NR_jail_remove_jd      598
 
-#define __NR_fake_sigreturn      1000
+#define __NR_freebsd_fake_sigreturn 1000
 
 #endif /* VKI_UNISTD_FREEBSD_H */