diff --git a/lib/libtsan/sanitizer_common/sanitizer_linux.cpp b/lib/libtsan/sanitizer_common/sanitizer_linux.cpp index 16caf699a4..acb59dfd6b 100644 --- a/lib/libtsan/sanitizer_common/sanitizer_linux.cpp +++ b/lib/libtsan/sanitizer_common/sanitizer_linux.cpp @@ -174,8 +174,6 @@ 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 { @@ -265,9 +263,8 @@ 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 - return (uptr)__sys_mmap(addr, length, prot, flags, fd, offset); -# elif SANITIZER_LINUX_USES_64BIT_SYSCALLS + /* zig patch: use direct syscall for freebsd mmap */ +# if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS return internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd, offset); # else @@ -942,6 +939,11 @@ int internal_fork() { } # if SANITIZER_FREEBSD +int internal_sigaction(int signum, const void *act, void *oldact) { + /* zig patch: use direct syscall for freebsd mmap */ + return internal_syscall(SYSCALL(sigaction), signum, (uptr)act, (uptr)oldact); +} + int internal_sysctl(const int *name, unsigned int namelen, void *oldp, uptr *oldlenp, const void *newp, uptr newlen) { return internal_syscall(SYSCALL(__sysctl), name, namelen, oldp, diff --git a/lib/libtsan/sanitizer_common/sanitizer_linux_libcdep.cpp b/lib/libtsan/sanitizer_common/sanitizer_linux_libcdep.cpp index f5cb85bc1b..1263f307ac 100644 --- a/lib/libtsan/sanitizer_common/sanitizer_linux_libcdep.cpp +++ b/lib/libtsan/sanitizer_common/sanitizer_linux_libcdep.cpp @@ -69,8 +69,6 @@ # undef MAP_NORESERVE # define MAP_NORESERVE 0 extern const Elf_Auxinfo *__elf_aux_vector __attribute__((weak)); -extern "C" int __sys_sigaction(int signum, const struct sigaction *act, - struct sigaction *oldact); # endif # if SANITIZER_NETBSD @@ -100,24 +98,17 @@ namespace __sanitizer { SANITIZER_WEAK_ATTRIBUTE int real_sigaction(int signum, const void *act, void *oldact); +/* zig patch: use direct syscall for freebsd sigaction (sanitizer_linux.cpp) */ +# if !SANITIZER_FREEBSD int internal_sigaction(int signum, const void *act, void *oldact) { -# if SANITIZER_FREEBSD - // On FreeBSD, call the sigaction syscall directly (part of libsys in FreeBSD - // 15) since the libc version goes via a global interposing table. Due to - // library initialization order the table can be relocated after the call to - // InitializeDeadlySignals() which then crashes when dereferencing the - // uninitialized pointer in libc. - return __sys_sigaction(signum, (const struct sigaction *)act, - (struct sigaction *)oldact); -# else # if !SANITIZER_GO if (&real_sigaction) return real_sigaction(signum, act, oldact); # endif return sigaction(signum, (const struct sigaction *)act, (struct sigaction *)oldact); -# endif } +# endif void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top, uptr *stack_bottom) {