]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Darwin: various fixes
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 17 Feb 2024 20:37:00 +0000 (21:37 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 17 Feb 2024 20:37:00 +0000 (21:37 +0100)
Fix building a couple of regtests.
bmi.c - Apple clang puts a funky underscore before symbols which you
have to add explicitly in asm.
mmap_o_direct.c - there is no O_DIRECT on macOS
syswrap - make csrctl messages a bit more userland-y rather than
kernel-y

coregrind/m_syswrap/syswrap-darwin.c
none/tests/amd64/bmi.c
none/tests/mmap_o_direct.c

index 61e7f6e6e2311b6d19ce639386004bb4fcb06047..fd5cb93cefa6b4c41cdf904e7d63e6e9fa1d59ff 100644 (file)
@@ -9817,20 +9817,24 @@ PRE(bsdthread_ctl)
                  void*, cmd, void*, arg1, void*, arg2, void*, arg3);
 }
 
+// syscalls.master says
+// int csrctl(uint32_t op, user_addr_t useraddr, user_addr_t usersize) NO_SYSCALL_STUB;
+// but https://github.com/search?q=repo%3Aapple-open-source%2Fmacos%20__csrctl&type=code says
+// int __csrctl(csr_op_t op, void *buffer, size_t size);
 PRE(csrctl)
 {
    switch (ARG1) {
    case VKI_CSR_CHECK:
      PRINT("csrctl(op:CSR_CHECK, useraddr:%#lx, usersize:%#lx)", ARG2, ARG3);
-   PRE_REG_READ3(int, "csrctl",
-                 uint32_t, op, user_addr_t, useraddr, user_addr_t, usersize);
+     PRE_REG_READ3(int, "csrctl",
+                   uint32_t, op, void*, useraddr, size_t, usersize);
      PRE_MEM_READ( "csrctl(useraddr)", ARG2, ARG3 );
      break;
 
    case VKI_CSR_GET_ACTIVE_CONFIG:
       PRINT("csrctl(op:CSR_GET_ACTIVE_CONFIG, useraddr:%#lx, usersize:%#lx)", ARG2, ARG3);
       PRE_REG_READ3(int, "csrctl",
-                    uint32_t, op, user_addr_t, useraddr, user_addr_t, usersize);
+                    uint32_t, op, void*, useraddr, size_t, usersize);
       PRE_MEM_WRITE( "csrctl(useraddr)", ARG2, ARG3 );
       break;
 
index 43c56f623d92311322abebbe84d3b9e2cf5f7402..a0a62eba0146cbf7d9fb49a945cf37bc0e899db4 100644 (file)
@@ -414,7 +414,11 @@ void do_rorx64 ( /*OUT*/ULong* res1, /*OUT*/ULong* res2, ULong arg )
     "xorq $0x8d5, (%%rsp)"    "\n\t"
     "movq (%%rsp), %1"        "\n\t"
     "popfq"                   "\n\t"
+#if defined(__APPLE__)
+    "rorx $67, _g_ulong_arg(%%rip), %0" "\n\t"
+#else
     "rorx $67, g_ulong_arg(%%rip), %0" "\n\t"
+#endif
     "pushfq"                  "\n\t"
     "movq (%%rsp), %2"        "\n\t"
     "xorq $0x8d5, (%%rsp)"    "\n\t"
@@ -469,7 +473,11 @@ void do_rorx32 ( /*OUT*/ULong* res1, /*OUT*/ULong* res2, UInt arg )
     "xorq $0x8d5, (%%rsp)"    "\n\t"
     "movq (%%rsp), %1"        "\n\t"
     "popfq"                   "\n\t"
+#if defined(__APPLE__)
+    "rorx $67, _g_uint_arg(%%rip), %k0" "\n\t"
+#else
     "rorx $67, g_uint_arg(%%rip), %k0" "\n\t"
+#endif
     "pushfq"                  "\n\t"
     "movq (%%rsp), %2"        "\n\t"
     "xorq $0x8d5, (%%rsp)"    "\n\t"
index b71339172685942f50ff513971ffd9be37095147..9a877f91789ab3b6996c944b4cfffd09139b2268 100644 (file)
@@ -3,6 +3,9 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <stddef.h>
+#if !defined(O_DIRECT)
+#define O_DIRECT 0
+#endif
 
 int main(void)
 {