[compiler-rt] b0b4906 - [compiler-rt] Call __sys_mmap in internal_mmap on FreeBSD

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 2 14:52:34 PDT 2024


Author: Alexander Richardson
Date: 2024-08-02T14:52:31-07:00
New Revision: b0b490634000b68293eca4be67b59738766a8632

URL: https://github.com/llvm/llvm-project/commit/b0b490634000b68293eca4be67b59738766a8632
DIFF: https://github.com/llvm/llvm-project/commit/b0b490634000b68293eca4be67b59738766a8632.diff

LOG: [compiler-rt] Call __sys_mmap in internal_mmap on FreeBSD

Due to the slightly non-standard interface that returns a pointer
rather than just an integer, the __syscall() utility cannot be used
on all architectures. This change is required for example to use the
sanitizers on Arm Morello.

Pull Request: https://github.com/llvm/llvm-project/pull/84438

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index fd5ff1b400545..73f07c7b22dc5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -152,6 +152,8 @@ const int FUTEX_WAKE_PRIVATE = FUTEX_WAKE | FUTEX_PRIVATE_FLAG;
 
 #  if SANITIZER_FREEBSD
 #    define SANITIZER_USE_GETENTROPY 1
+extern "C" void *__sys_mmap(void *addr, size_t len, int prot, int flags, int fd,
+                            off_t offset);
 #  endif
 
 namespace __sanitizer {
@@ -218,7 +220,9 @@ ScopedBlockSignals::~ScopedBlockSignals() { SetSigProcMask(&saved_, nullptr); }
 #    if !SANITIZER_S390
 uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
                    u64 offset) {
-#      if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
+#      if SANITIZER_FREEBSD
+  return (uptr)__sys_mmap(addr, length, prot, flags, fd, offset);
+#      elif SANITIZER_LINUX_USES_64BIT_SYSCALLS
   return internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd,
                           offset);
 #      else


        


More information about the llvm-commits mailing list