-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[compiler-rt][sanitizer] add Haiku support #134772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-compiler-rt-sanitizer @llvm/pr-subscribers-llvm-transforms Author: Brad Smith (brad0) ChangesPatch is 52.77 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/134772.diff 27 Files Affected:
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index f319113e5c16e..9f8e8334d75ba 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -569,6 +569,10 @@ append_list_if(COMPILER_RT_HAS_LIBC c SANITIZER_COMMON_LINK_LIBS)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
list(APPEND SANITIZER_COMMON_LINK_LIBS zircon)
endif()
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku")
+ list(APPEND SANITIZER_COMMON_LINK_LIBS root)
+ list(APPEND SANITIZER_COMMON_LINK_LIBS bsd)
+endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
set(SANITIZER_NO_UNDEFINED_SYMBOLS_DEFAULT ON)
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index cf729c3adb1f5..e3310b1ff0e2c 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -760,7 +760,7 @@ set(COMPILER_RT_SANITIZERS_TO_BUILD all CACHE STRING
list_replace(COMPILER_RT_SANITIZERS_TO_BUILD all "${ALL_SANITIZERS}")
if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
- (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD|NetBSD|Fuchsia|SunOS" OR
+ (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD|NetBSD|Fuchsia|SunOS|Haiku" OR
(OS_NAME MATCHES "Windows" AND NOT CYGWIN AND
(NOT MINGW OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"))))
set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)
@@ -875,7 +875,7 @@ else()
endif()
if (COMPILER_RT_HAS_SANITIZER_COMMON AND UBSAN_SUPPORTED_ARCH AND
- OS_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|Windows|Android|Fuchsia|SunOS")
+ OS_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|Windows|Android|Fuchsia|SunOS|Haiku")
set(COMPILER_RT_HAS_UBSAN TRUE)
else()
set(COMPILER_RT_HAS_UBSAN FALSE)
diff --git a/compiler-rt/lib/asan/asan_linux.cpp b/compiler-rt/lib/asan/asan_linux.cpp
index 3b40f76836efe..b3aa3ead187bc 100644
--- a/compiler-rt/lib/asan/asan_linux.cpp
+++ b/compiler-rt/lib/asan/asan_linux.cpp
@@ -13,7 +13,11 @@
#include "sanitizer_common/sanitizer_platform.h"
#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \
- SANITIZER_SOLARIS
+ SANITIZER_SOLARIS || SANITIZER_HAIKU
+
+# if SANITIZER_HAIKU
+# define _DEFAULT_SOURCE
+# endif
# include <dlfcn.h>
# include <fcntl.h>
@@ -22,7 +26,9 @@
# include <stdio.h>
# include <sys/mman.h>
# include <sys/resource.h>
+#if !SANITIZER_HAIKU
# include <sys/syscall.h>
+#endif
# include <sys/time.h>
# include <sys/types.h>
# include <unistd.h>
@@ -37,7 +43,7 @@
# include "sanitizer_common/sanitizer_libc.h"
# include "sanitizer_common/sanitizer_procmaps.h"
-# if SANITIZER_FREEBSD
+# if SANITIZER_FREEBSD || SANITIZER_HAIKU
# include <sys/link_elf.h>
# endif
@@ -54,6 +60,8 @@
# elif SANITIZER_NETBSD
# include <link_elf.h>
# include <ucontext.h>
+# elif SANITIZER_HAIKU
+extern "C" void* _DYNAMIC;
# else
# include <link.h>
# include <sys/ucontext.h>
@@ -162,6 +170,12 @@ static int FindFirstDSOCallback(struct dl_phdr_info *info, size_t size,
return 0;
}
+# if SANITIZER_HAIKU
+ if (!info->dlpi_name[0] ||
+ internal_strncmp(info->dlpi_name, "/boot/system/runtime_loader",
+ sizeof("/boot/system/runtime_loader") - 1) == 0)
+ return 0;
+# endif
# if SANITIZER_LINUX
// Ignore vDSO. glibc versions earlier than 2.15 (and some patched
// by distributors) return an empty name for the vDSO entry, so
diff --git a/compiler-rt/lib/asan/asan_malloc_linux.cpp b/compiler-rt/lib/asan/asan_malloc_linux.cpp
index 3d6b03fefab70..cbcdd9c1be29d 100644
--- a/compiler-rt/lib/asan/asan_malloc_linux.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_linux.cpp
@@ -15,7 +15,7 @@
#include "sanitizer_common/sanitizer_platform.h"
#if SANITIZER_FREEBSD || SANITIZER_FUCHSIA || SANITIZER_LINUX || \
- SANITIZER_NETBSD || SANITIZER_SOLARIS
+ SANITIZER_NETBSD || SANITIZER_SOLARIS || SANITIZER_HAIKU
# include "asan_allocator.h"
# include "asan_interceptors.h"
diff --git a/compiler-rt/lib/asan/asan_posix.cpp b/compiler-rt/lib/asan/asan_posix.cpp
index 39685696a0d0d..401df415096dd 100644
--- a/compiler-rt/lib/asan/asan_posix.cpp
+++ b/compiler-rt/lib/asan/asan_posix.cpp
@@ -174,7 +174,7 @@ static void AfterFork(bool fork_child) {
void InstallAtForkHandler() {
# if SANITIZER_SOLARIS || SANITIZER_NETBSD || SANITIZER_APPLE || \
- (SANITIZER_LINUX && SANITIZER_SPARC)
+ (SANITIZER_LINUX && SANITIZER_SPARC) || SANITIZER_HAIKU
// While other Linux targets use clone in internal_fork which doesn't
// trigger pthread_atfork handlers, Linux/sparc64 uses __fork, causing a
// hang.
diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt
index 00dcbf6534e28..9cd9c97bed813 100644
--- a/compiler-rt/lib/asan/tests/CMakeLists.txt
+++ b/compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -109,6 +109,7 @@ if(NOT APPLE)
append_list_if(COMPILER_RT_HAS_LIBM -lm ASAN_UNITTEST_NOINST_LINK_FLAGS)
append_list_if(COMPILER_RT_HAS_LIBDL -ldl ASAN_UNITTEST_NOINST_LINK_FLAGS)
append_list_if(COMPILER_RT_HAS_LIBRT -lrt ASAN_UNITTEST_NOINST_LINK_FLAGS)
+ append_list_if(HAIKU -lbsd ASAN_UNITTEST_NOINST_LINK_FLAGS)
append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread ASAN_UNITTEST_NOINST_LINK_FLAGS)
append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS)
endif()
diff --git a/compiler-rt/lib/asan/tests/asan_test.cpp b/compiler-rt/lib/asan/tests/asan_test.cpp
index 0d98b1498a821..2d054ee859ed4 100644
--- a/compiler-rt/lib/asan/tests/asan_test.cpp
+++ b/compiler-rt/lib/asan/tests/asan_test.cpp
@@ -1163,7 +1163,7 @@ TEST(AddressSanitizer, DISABLED_StressStackReuseAndExceptionsTest) {
}
#endif
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__HAIKU__)
TEST(AddressSanitizer, MlockTest) {
EXPECT_EQ(0, mlockall(MCL_CURRENT));
EXPECT_EQ(0, mlock((void *)0x12345, 0x5678));
diff --git a/compiler-rt/lib/interception/interception.h b/compiler-rt/lib/interception/interception.h
index 3cb6b446638e0..25480120e7ad6 100644
--- a/compiler-rt/lib/interception/interception.h
+++ b/compiler-rt/lib/interception/interception.h
@@ -19,7 +19,7 @@
#if !SANITIZER_LINUX && !SANITIZER_FREEBSD && !SANITIZER_APPLE && \
!SANITIZER_NETBSD && !SANITIZER_WINDOWS && !SANITIZER_FUCHSIA && \
- !SANITIZER_SOLARIS
+ !SANITIZER_SOLARIS && !SANITIZER_HAIKU
# error "Interception doesn't work on this operating system."
#endif
@@ -368,7 +368,7 @@ inline void DoesNotSupportStaticLinking() {}
#define INCLUDED_FROM_INTERCEPTION_LIB
#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
- SANITIZER_SOLARIS
+ SANITIZER_SOLARIS || SANITIZER_HAIKU
# include "interception_linux.h"
# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
diff --git a/compiler-rt/lib/interception/interception_linux.cpp b/compiler-rt/lib/interception/interception_linux.cpp
index ef8136eb4fc70..0a6659d38ae83 100644
--- a/compiler-rt/lib/interception/interception_linux.cpp
+++ b/compiler-rt/lib/interception/interception_linux.cpp
@@ -14,7 +14,7 @@
#include "interception.h"
#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
- SANITIZER_SOLARIS
+ SANITIZER_SOLARIS || SANITIZER_HAIKU
#include <dlfcn.h> // for dlsym() and dlvsym()
diff --git a/compiler-rt/lib/interception/interception_linux.h b/compiler-rt/lib/interception/interception_linux.h
index 2e01ff44578c3..52e34d535030e 100644
--- a/compiler-rt/lib/interception/interception_linux.h
+++ b/compiler-rt/lib/interception/interception_linux.h
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
- SANITIZER_SOLARIS
+ SANITIZER_SOLARIS || SANITIZER_HAIKU
#if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
# error interception_linux.h should be included from interception library only
diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index 09391e4f5f370..6e6dfd2f33ebf 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -11,6 +11,7 @@ set(SANITIZER_SOURCES_NOTERMINATION
sanitizer_flags.cpp
sanitizer_flag_parser.cpp
sanitizer_fuchsia.cpp
+ sanitizer_haiku.cpp
sanitizer_libc.cpp
sanitizer_libignore.cpp
sanitizer_linux.cpp
@@ -28,6 +29,7 @@ set(SANITIZER_SOURCES_NOTERMINATION
sanitizer_procmaps_common.cpp
sanitizer_procmaps_bsd.cpp
sanitizer_procmaps_fuchsia.cpp
+ sanitizer_procmaps_haiku.cpp
sanitizer_procmaps_linux.cpp
sanitizer_procmaps_mac.cpp
sanitizer_procmaps_solaris.cpp
@@ -227,6 +229,9 @@ set(SANITIZER_COMMON_DEFINITIONS
# note: L not I, this is nodefaultlibs for msvc
append_list_if(MSVC /Zl SANITIZER_COMMON_CFLAGS)
+if(HAIKU)
+ list(APPEND SANITIZER_COMMON_CFLAGS -I/system/develop/headers/private -I/system/develop/headers/private/system/arch/x86_64 -I/system/develop/headers/private/system)
+endif()
set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
# Too many existing bugs, needs cleanup.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
index 49ec4097c900b..f88f914b1d149 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
@@ -48,35 +48,39 @@ static void ioctl_table_fill() {
++ioctl_table_size; \
}
+ _(FIONBIO, READ, sizeof(int));
+#if !SANITIZER_HAIKU
_(FIOASYNC, READ, sizeof(int));
_(FIOCLEX, NONE, 0);
_(FIOGETOWN, WRITE, sizeof(int));
- _(FIONBIO, READ, sizeof(int));
_(FIONCLEX, NONE, 0);
_(FIOSETOWN, READ, sizeof(int));
+#endif
_(SIOCATMARK, WRITE, sizeof(int));
_(SIOCGIFCONF, CUSTOM, 0);
_(SIOCGPGRP, WRITE, sizeof(int));
_(SIOCSPGRP, READ, sizeof(int));
-#if !SANITIZER_SOLARIS
+#if !SANITIZER_SOLARIS && !SANITIZER_HAIKU
_(TIOCCONS, NONE, 0);
#endif
- _(TIOCEXCL, NONE, 0);
+#if !SANITIZER_HAIKU
_(TIOCGETD, WRITE, sizeof(int));
+ _(TIOCNOTTY, NONE, 0);
+ _(TIOCPKT, READ, sizeof(int));
+ _(TIOCSETD, READ, sizeof(int));
+ _(TIOCSTI, READ, sizeof(char));
+#endif
+ _(TIOCEXCL, NONE, 0);
_(TIOCGPGRP, WRITE, pid_t_sz);
_(TIOCGWINSZ, WRITE, struct_winsize_sz);
_(TIOCMBIC, READ, sizeof(int));
_(TIOCMBIS, READ, sizeof(int));
_(TIOCMGET, WRITE, sizeof(int));
_(TIOCMSET, READ, sizeof(int));
- _(TIOCNOTTY, NONE, 0);
_(TIOCNXCL, NONE, 0);
_(TIOCOUTQ, WRITE, sizeof(int));
- _(TIOCPKT, READ, sizeof(int));
_(TIOCSCTTY, NONE, 0);
- _(TIOCSETD, READ, sizeof(int));
_(TIOCSPGRP, READ, pid_t_sz);
- _(TIOCSTI, READ, sizeof(char));
_(TIOCSWINSZ, READ, struct_winsize_sz);
#if !SANITIZER_IOS
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_errno.h b/compiler-rt/lib/sanitizer_common/sanitizer_errno.h
index 46c85364cef56..76919da57d942 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_errno.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_errno.h
@@ -29,6 +29,8 @@
# define __errno_location ___errno
#elif SANITIZER_WINDOWS
# define __errno_location _errno
+#elif SANITIZER_HAIKU
+# define __errno_location _errnop
#endif
extern "C" int *__errno_location();
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h b/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
index 9e6e71ec80c15..c2ea52b84dfc3 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
@@ -21,12 +21,21 @@
namespace __sanitizer {
+#ifdef __HAIKU__
+#define errno_ENOMEM (0x80000000)
+#define errno_EBUSY (0x80000000 + 14)
+#define errno_EINVAL (0x80000000 + 5)
+#define errno_ERANGE (0x80007000 + 17)
+#define errno_ENAMETOOLONG (0x80000000 + 0x6004)
+#define errno_ENOSYS (0x80007009)
+#else
#define errno_ENOMEM 12
#define errno_EBUSY 16
#define errno_EINVAL 22
#define errno_ERANGE 34
#define errno_ENAMETOOLONG 36
#define errno_ENOSYS 38
+#endif
// Those might not present or their value differ on different platforms.
extern const int errno_EOWNERDEAD;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp
new file mode 100644
index 0000000000000..9b721775422ee
--- /dev/null
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp
@@ -0,0 +1,361 @@
+//===-- sanitizer_haiku.cpp -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is shared between Sanitizer run-time libraries and implements
+// Haiku-specific functions from sanitizer_libc.h.
+//===----------------------------------------------------------------------===//
+
+#include "sanitizer_platform.h"
+
+#if SANITIZER_HAIKU
+
+#include "sanitizer_common.h"
+#include "sanitizer_flags.h"
+#include "sanitizer_getauxval.h"
+#include "sanitizer_internal_defs.h"
+#include "sanitizer_libc.h"
+#include "sanitizer_linux.h"
+#include "sanitizer_mutex.h"
+#include "sanitizer_placement_new.h"
+#include "sanitizer_procmaps.h"
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <sys/mman.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <link.h>
+#include <pthread.h>
+#include <sched.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include "system/vm_defs.h"
+#include "system/syscalls.h"
+#include "shared/syscall_utils.h"
+
+namespace __sanitizer {
+
+static void *GetRealLibcAddress(const char *symbol) {
+ void *real = dlsym(RTLD_NEXT, symbol);
+ if (!real)
+ real = dlsym(RTLD_DEFAULT, symbol);
+ if (!real) {
+ Printf("GetRealLibcAddress failed for symbol=%s", symbol);
+ Die();
+ }
+ return real;
+}
+
+#define _REAL(func, ...) real##_##func(__VA_ARGS__)
+#define DEFINE__REAL(ret_type, func, ...) \
+ static ret_type (*real_##func)(__VA_ARGS__) = NULL; \
+ if (!real_##func) { \
+ real_##func = (ret_type(*)(__VA_ARGS__))GetRealLibcAddress(#func); \
+ } \
+ CHECK(real_##func);
+
+// --------------- sanitizer_libc.h
+uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
+ u64 offset) {
+ if ((flags & MAP_ANONYMOUS) != 0)
+ fd = -1;
+
+ int mapping = (flags & MAP_SHARED) != 0
+ ? REGION_NO_PRIVATE_MAP : REGION_PRIVATE_MAP;
+
+ uint32 addressSpec;
+ if ((flags & MAP_FIXED) != 0)
+ addressSpec = B_EXACT_ADDRESS;
+ else if (addr != NULL)
+ addressSpec = B_BASE_ADDRESS;
+ else
+ addressSpec = B_RANDOMIZED_ANY_ADDRESS;
+
+ uint32 areaProtection = 0;
+ if ((prot & PROT_READ) != 0)
+ areaProtection |= B_READ_AREA;
+ if ((prot & PROT_WRITE) != 0)
+ areaProtection |= B_WRITE_AREA;
+ if ((prot & PROT_EXEC) != 0)
+ areaProtection |= B_EXECUTE_AREA;
+
+ if ((flags & MAP_NORESERVE) != 0)
+ areaProtection |= B_OVERCOMMITTING_AREA;
+
+ area_id area = _kern_map_file("sanitizer mmap", &addr, addressSpec, length,
+ areaProtection, mapping, true, fd, offset);
+ if (area < 0)
+ RETURN_AND_SET_ERRNO(area);
+ return (uptr)addr;
+}
+
+uptr internal_munmap(void *addr, uptr length) {
+ DEFINE__REAL(int, munmap, void *a, uptr b);
+ return _REAL(munmap, addr, length);
+}
+
+uptr internal_mremap(void *old_address, uptr old_size, uptr new_size, int flags,
+ void *new_address) {
+ CHECK(false && "internal_mremap is unimplemented on Haiku");
+ return 0;
+}
+
+int internal_mprotect(void *addr, uptr length, int prot) {
+ DEFINE__REAL(int, mprotect, void *a, uptr b, int c);
+ return _REAL(mprotect, addr, length, prot);
+}
+
+int internal_madvise(uptr addr, uptr length, int advice) {
+ DEFINE__REAL(int, madvise, void *a, uptr b, int c);
+ return _REAL(madvise, (void *)addr, length, advice);
+}
+
+uptr internal_close(fd_t fd) {
+ CHECK(&_kern_close);
+ RETURN_AND_SET_ERRNO(_kern_close(fd));
+}
+
+uptr internal_open(const char *filename, int flags) {
+ CHECK(&_kern_open);
+ RETURN_AND_SET_ERRNO(_kern_open(-1, filename, flags, 0));
+}
+
+uptr internal_open(const char *filename, int flags, u32 mode) {
+ CHECK(&_kern_open);
+ RETURN_AND_SET_ERRNO(_kern_open(-1, filename, flags, mode));
+}
+
+uptr internal_read(fd_t fd, void *buf, uptr count) {
+ sptr res;
+ CHECK(&_kern_read);
+ HANDLE_EINTR(res, (sptr)_kern_read(fd, -1, buf, (size_t)count));
+ RETURN_AND_SET_ERRNO(res);
+ return res;
+}
+
+uptr internal_write(fd_t fd, const void *buf, uptr count) {
+ sptr res;
+ CHECK(&_kern_write);
+ HANDLE_EINTR(res, (sptr)_kern_write(fd, -1, buf, count));
+ RETURN_AND_SET_ERRNO(res);
+ return res;
+}
+
+uptr internal_ftruncate(fd_t fd, uptr size) {
+ sptr res;
+ DEFINE__REAL(int, ftruncate, int, off_t);
+ return _REAL(ftruncate, fd, size);
+ return res;
+}
+
+uptr internal_stat(const char *path, void *buf) {
+ DEFINE__REAL(int, _stat_current, const char *a, void *b);
+ return _REAL(_stat_current, path, buf);
+}
+
+uptr internal_lstat(const char *path, void *buf) {
+ DEFINE__REAL(int, _lstat_current, const char *a, void *b);
+ return _REAL(_lstat_current, path, buf);
+}
+
+uptr internal_fstat(fd_t fd, void *buf) {
+ DEFINE__REAL(int, _fstat_current, int a, void *b);
+ return _REAL(_fstat_current, fd, buf);
+}
+
+uptr internal_filesize(fd_t fd) {
+ struct stat st;
+ if (internal_fstat(fd, &st))
+ return -1;
+ return (uptr)st.st_size;
+}
+
+uptr internal_dup(int oldfd) {
+ DEFINE__REAL(int, dup, int a);
+ return _REAL(dup, oldfd);
+}
+
+uptr internal_dup2(int oldfd, int newfd) {
+ DEFINE__REAL(int, dup2, int a, int b);
+ return _REAL(dup2, oldfd, newfd);
+}
+
+uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
+ CHECK(&_kern_read_link);
+ RETURN_AND_SET_ERRNO(_kern_read_link(-1, path, buf, &bufsize));
+}
+
+uptr internal_unlink(const char *path) {
+ DEFINE__REAL(int, unlink, const char *a);
+ return _REAL(unlink, path);
+}
+
+uptr internal_rename(const char *oldpath, const char *newpath) {
+ DEFINE__REAL(int, rename, const char *a, const char *b);
+ return _REAL(rename, oldpath, newpath);
+}
+
+uptr internal_sched_yield() {
+ CHECK(&_kern_thread_yield);
+ _kern_thread_yield();
+ return 0;
+}
+
+void internal__exit(int exitcode) {
+ DEFINE__REAL(void, _exit, int a);
+ _REAL(_exit, exitcode);
+ Die(); // Unreachable.
+}
+
+void internal_usleep(u64 useconds) {
+ _kern_snooze_etc(useconds, B_SYSTEM_TIMEBASE, B_RELATIVE_TIMEOUT, NULL);
+}
+
+uptr internal_execve(const char *filename, char *const argv[],
+ char *const envp[]) {
+ DEFINE__REAL(int, execve, const char*, char*const[], char*const[]);
+ return _REAL(execve, filename, argv, envp);
+}
+
+#if 0
+tid_t GetTid() {
+ DEFINE__REAL(int, _lwp_self);
+ return _REAL(_lwp_self);
+}
+
+int TgKill(pid_t pid, tid_t tid, int sig) {
+ DEFINE__REAL(int, _lwp_kill, int a, int b);
+ (void)pid;
+ return _REAL(_lwp_kill, tid, sig);
+}
+
+u64 NanoTime() {
+ timeval tv;
+ DEFINE__REAL(int, __gettimeofday50, void *a, void *b);
+ internal_memset(&tv, 0, sizeof(tv));
+ _REAL(__gettimeofday50, &tv, 0);
+ return (u64)tv.tv_sec * 1000 * 1000 * 1000 + tv.tv_usec * 1000;
+}
+#endif
+
+uptr internal_clock_gettime(__sanitizer_clockid_t clk_id, void *tp) {
+ DEFINE__REAL(int, __clock_gettime50, __sanitizer_clockid_t a, void *b);
+ return _REAL(__clock_gettime50, clk_id, tp);
+}
+
+uptr internal_ptrace(int request, int pid, void *addr, int data) {
+ DEFINE__REAL(int, ptrace, int a, int b, void *c, int d);
+ return _REAL(ptrace, request, pid, addr, data);
+}
+
+uptr internal_waitpid(int pid, int *status, int options) {
+ DEFINE__REAL(int, waitpid, pid_t, int*, int);
+ return _REAL(waitpid, pid, status, options);
+}
+
+uptr internal_getpid() {
+ DEFINE__REAL(int, getpid);
+ return _REAL(getpid);
+}
+
+uptr internal_getppid() {
+ DEFINE__REAL(int, getppid);
+ return _REAL(getppid);
+}
+
+int internal_dlinfo(...
[truncated]
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions inc,cpp,h -- compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp compiler-rt/lib/sanitizer_common/sanitizer_procmaps_haiku.cpp compiler-rt/lib/asan/asan_linux.cpp compiler-rt/lib/asan/asan_malloc_linux.cpp compiler-rt/lib/asan/asan_posix.cpp compiler-rt/lib/asan/tests/asan_test.cpp compiler-rt/lib/interception/interception.h compiler-rt/lib/interception/interception_linux.cpp compiler-rt/lib/interception/interception_linux.h compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc compiler-rt/lib/sanitizer_common/sanitizer_errno.h compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp compiler-rt/lib/sanitizer_common/sanitizer_linux.h compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform.h compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp compiler-rt/lib/ubsan/ubsan_platform.h llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp View the diff from clang-format here.diff --git a/compiler-rt/lib/interception/interception.h b/compiler-rt/lib/interception/interception.h
index 25480120e..4a7ff6e33 100644
--- a/compiler-rt/lib/interception/interception.h
+++ b/compiler-rt/lib/interception/interception.h
@@ -370,9 +370,9 @@ inline void DoesNotSupportStaticLinking() {}
#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
SANITIZER_SOLARIS || SANITIZER_HAIKU
-# include "interception_linux.h"
-# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
-# define INTERCEPT_FUNCTION_VER(func, symver) \
+# include "interception_linux.h"
+# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
+# define INTERCEPT_FUNCTION_VER(func, symver) \
INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver)
#elif SANITIZER_APPLE
# include "interception_mac.h"
diff --git a/compiler-rt/lib/interception/interception_linux.cpp b/compiler-rt/lib/interception/interception_linux.cpp
index 0a6659d38..b03e9c524 100644
--- a/compiler-rt/lib/interception/interception_linux.cpp
+++ b/compiler-rt/lib/interception/interception_linux.cpp
@@ -16,7 +16,7 @@
#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
SANITIZER_SOLARIS || SANITIZER_HAIKU
-#include <dlfcn.h> // for dlsym() and dlvsym()
+# include <dlfcn.h> // for dlsym() and dlvsym()
namespace __interception {
diff --git a/compiler-rt/lib/interception/interception_linux.h b/compiler-rt/lib/interception/interception_linux.h
index 52e34d535..f78ccc13e 100644
--- a/compiler-rt/lib/interception/interception_linux.h
+++ b/compiler-rt/lib/interception/interception_linux.h
@@ -14,12 +14,12 @@
#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
SANITIZER_SOLARIS || SANITIZER_HAIKU
-#if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
-# error interception_linux.h should be included from interception library only
-#endif
+# if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
+# error interception_linux.h should be included from interception library only
+# endif
-#ifndef INTERCEPTION_LINUX_H
-#define INTERCEPTION_LINUX_H
+# ifndef INTERCEPTION_LINUX_H
+# define INTERCEPTION_LINUX_H
namespace __interception {
bool InterceptFunction(const char *name, uptr *ptr_to_real, uptr func,
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
index f88f914b1..5b3df83f8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
@@ -49,27 +49,27 @@ static void ioctl_table_fill() {
}
_(FIONBIO, READ, sizeof(int));
-#if !SANITIZER_HAIKU
+# if !SANITIZER_HAIKU
_(FIOASYNC, READ, sizeof(int));
_(FIOCLEX, NONE, 0);
_(FIOGETOWN, WRITE, sizeof(int));
_(FIONCLEX, NONE, 0);
_(FIOSETOWN, READ, sizeof(int));
-#endif
+# endif
_(SIOCATMARK, WRITE, sizeof(int));
_(SIOCGIFCONF, CUSTOM, 0);
_(SIOCGPGRP, WRITE, sizeof(int));
_(SIOCSPGRP, READ, sizeof(int));
-#if !SANITIZER_SOLARIS && !SANITIZER_HAIKU
+# if !SANITIZER_SOLARIS && !SANITIZER_HAIKU
_(TIOCCONS, NONE, 0);
#endif
-#if !SANITIZER_HAIKU
+# if !SANITIZER_HAIKU
_(TIOCGETD, WRITE, sizeof(int));
_(TIOCNOTTY, NONE, 0);
_(TIOCPKT, READ, sizeof(int));
_(TIOCSETD, READ, sizeof(int));
_(TIOCSTI, READ, sizeof(char));
-#endif
+# endif
_(TIOCEXCL, NONE, 0);
_(TIOCGPGRP, WRITE, pid_t_sz);
_(TIOCGWINSZ, WRITE, struct_winsize_sz);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp
index 7cf2437d5..3578ec439 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_haiku.cpp
@@ -14,24 +14,6 @@
#if SANITIZER_HAIKU
-# include "sanitizer_common.h"
-# include "sanitizer_flags.h"
-# include "sanitizer_getauxval.h"
-# include "sanitizer_internal_defs.h"
-# include "sanitizer_libc.h"
-# include "sanitizer_linux.h"
-# include "sanitizer_mutex.h"
-# include "sanitizer_placement_new.h"
-# include "sanitizer_procmaps.h"
-
-# include <sys/param.h>
-# include <sys/types.h>
-
-# include <sys/mman.h>
-# include <sys/resource.h>
-# include <sys/stat.h>
-# include <sys/time.h>
-
# include <dlfcn.h>
# include <errno.h>
# include <fcntl.h>
@@ -40,11 +22,26 @@
# include <pthread.h>
# include <sched.h>
# include <signal.h>
+# include <sys/mman.h>
+# include <sys/param.h>
+# include <sys/resource.h>
+# include <sys/stat.h>
+# include <sys/time.h>
+# include <sys/types.h>
# include <unistd.h>
-# include "system/vm_defs.h"
-# include "system/syscalls.h"
+# include "sanitizer_common.h"
+# include "sanitizer_flags.h"
+# include "sanitizer_getauxval.h"
+# include "sanitizer_internal_defs.h"
+# include "sanitizer_libc.h"
+# include "sanitizer_linux.h"
+# include "sanitizer_mutex.h"
+# include "sanitizer_placement_new.h"
+# include "sanitizer_procmaps.h"
# include "shared/syscall_utils.h"
+# include "system/syscalls.h"
+# include "system/vm_defs.h"
namespace __sanitizer {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
index edb619f4d..3ccdd0a72 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -52,50 +52,50 @@
#include <time.h>
#include <wchar.h>
#include <regex.h>
-#if !SANITIZER_APPLE && !SANITIZER_HAIKU
-#include <utmp.h>
-#endif
+# if !SANITIZER_APPLE && !SANITIZER_HAIKU
+# include <utmp.h>
+# endif
-#if !SANITIZER_IOS
-#include <net/route.h>
-#endif
+# if !SANITIZER_IOS
+# include <net/route.h>
+# endif
-#if !SANITIZER_ANDROID
-#if !SANITIZER_HAIKU
-#include <sys/mount.h>
-#endif
-#include <sys/timeb.h>
-#include <utmpx.h>
-#endif
+# if !SANITIZER_ANDROID
+# if !SANITIZER_HAIKU
+# include <sys/mount.h>
+# endif
+# include <sys/timeb.h>
+# include <utmpx.h>
+# endif
-#if SANITIZER_LINUX
-#include <malloc.h>
-#include <mntent.h>
-#include <netinet/ether.h>
-#include <sys/sysinfo.h>
-#include <sys/vt.h>
-#include <linux/cdrom.h>
-#include <linux/fd.h>
-#if SANITIZER_ANDROID
-#include <linux/fs.h>
-#endif
-#include <linux/hdreg.h>
-#include <linux/input.h>
-#include <linux/ioctl.h>
-#include <linux/soundcard.h>
-#include <linux/sysctl.h>
-#include <linux/utsname.h>
-#include <linux/posix_types.h>
-#include <net/if_arp.h>
-#endif
+# if SANITIZER_LINUX
+# include <malloc.h>
+# include <mntent.h>
+# include <netinet/ether.h>
+# include <sys/sysinfo.h>
+# include <sys/vt.h>
+# include <linux/cdrom.h>
+# include <linux/fd.h>
+# if SANITIZER_ANDROID
+# include <linux/fs.h>
+# endif
+# include <linux/hdreg.h>
+# include <linux/input.h>
+# include <linux/ioctl.h>
+# include <linux/soundcard.h>
+# include <linux/sysctl.h>
+# include <linux/utsname.h>
+# include <linux/posix_types.h>
+# include <net/if_arp.h>
+# endif
-#if SANITIZER_IOS
-#undef IOC_DIRMASK
-#endif
+# if SANITIZER_IOS
+# undef IOC_DIRMASK
+# endif
-#if SANITIZER_LINUX
-# include <utime.h>
-# include <sys/ptrace.h>
+# if SANITIZER_LINUX
+# include <utime.h>
+# include <sys/ptrace.h>
# if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \
defined(__hexagon__) || defined(__loongarch__) || SANITIZER_RISCV64 || \
defined(__sparc__) || defined(__powerpc64__)
@@ -113,15 +113,15 @@ typedef struct user_fpregs elf_fpregset_t;
#if !SANITIZER_ANDROID
#include <ifaddrs.h>
-#if !SANITIZER_HAIKU
-#include <sys/ucontext.h>
-#include <wordexp.h>
-#endif
-#endif
+# if !SANITIZER_HAIKU
+# include <sys/ucontext.h>
+# include <wordexp.h>
+# endif
+# endif
-#if SANITIZER_LINUX
-#if SANITIZER_GLIBC
-#include <fstab.h>
+# if SANITIZER_LINUX
+# if SANITIZER_GLIBC
+# include <fstab.h>
# include <linux/filter.h>
# include <net/if_ppp.h>
# include <netax25/ax25.h>
@@ -132,55 +132,55 @@ typedef struct user_fpregs elf_fpregset_t;
# include <rpc/xdr.h>
# endif
# include <scsi/scsi.h>
-#else
-#include <linux/if_ppp.h>
-#include <linux/kd.h>
-#include <linux/ppp_defs.h>
-#endif // SANITIZER_GLIBC
-
-#if SANITIZER_ANDROID
-#include <linux/mtio.h>
-#else
-#include <glob.h>
-#include <mqueue.h>
-#include <sys/kd.h>
-#include <sys/mtio.h>
-#include <sys/shm.h>
-#include <sys/statvfs.h>
-#include <sys/timex.h>
-#if defined(__mips64)
-# include <sys/procfs.h>
-#endif
-#include <sys/user.h>
-#include <linux/if_eql.h>
-#include <linux/if_plip.h>
-#include <linux/lp.h>
-#include <linux/mroute.h>
-#include <linux/mroute6.h>
-#include <linux/scc.h>
-#include <linux/serial.h>
-#include <sys/msg.h>
-#include <sys/ipc.h>
-#endif // SANITIZER_ANDROID
-
-#include <link.h>
-#include <sys/vfs.h>
-#include <sys/epoll.h>
-#include <linux/capability.h>
-#elif !SANITIZER_HAIKU
-#include <fstab.h>
-#endif // SANITIZER_LINUX
+# else
+# include <linux/if_ppp.h>
+# include <linux/kd.h>
+# include <linux/ppp_defs.h>
+# endif // SANITIZER_GLIBC
-#if SANITIZER_APPLE
-#include <net/ethernet.h>
-#include <sys/filio.h>
-#include <sys/sockio.h>
-#endif
+# if SANITIZER_ANDROID
+# include <linux/mtio.h>
+# else
+# include <glob.h>
+# include <mqueue.h>
+# include <sys/kd.h>
+# include <sys/mtio.h>
+# include <sys/shm.h>
+# include <sys/statvfs.h>
+# include <sys/timex.h>
+# if defined(__mips64)
+# include <sys/procfs.h>
+# endif
+# include <sys/user.h>
+# include <linux/if_eql.h>
+# include <linux/if_plip.h>
+# include <linux/lp.h>
+# include <linux/mroute.h>
+# include <linux/mroute6.h>
+# include <linux/scc.h>
+# include <linux/serial.h>
+# include <sys/msg.h>
+# include <sys/ipc.h>
+# endif // SANITIZER_ANDROID
+
+# include <link.h>
+# include <sys/vfs.h>
+# include <sys/epoll.h>
+# include <linux/capability.h>
+# elif !SANITIZER_HAIKU
+# include <fstab.h>
+# endif // SANITIZER_LINUX
+
+# if SANITIZER_APPLE
+# include <net/ethernet.h>
+# include <sys/filio.h>
+# include <sys/sockio.h>
+# endif
-#if SANITIZER_HAIKU
-#include <sys/sockio.h>
-#include <sys/ioctl.h>
-#endif
+# if SANITIZER_HAIKU
+# include <sys/ioctl.h>
+# include <sys/sockio.h>
+# endif
// Include these after system headers to avoid name clashes and ambiguities.
# include "sanitizer_common.h"
@@ -226,7 +226,7 @@ namespace __sanitizer {
unsigned struct_fstab_sz = sizeof(struct fstab);
#endif // SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD ||
// SANITIZER_APPLE
-#if !SANITIZER_ANDROID && !SANITIZER_HAIKU
+# if !SANITIZER_ANDROID && !SANITIZER_HAIKU
unsigned struct_statfs_sz = sizeof(struct statfs);
unsigned struct_sockaddr_sz = sizeof(struct sockaddr);
@@ -333,7 +333,7 @@ namespace __sanitizer {
int shmctl_shm_stat = (int)SHM_STAT;
#endif
-#if !SANITIZER_APPLE && !SANITIZER_FREEBSD && !SANITIZER_HAIKU
+# if !SANITIZER_APPLE && !SANITIZER_FREEBSD && !SANITIZER_HAIKU
unsigned struct_utmp_sz = sizeof(struct utmp);
#endif
#if !SANITIZER_ANDROID
@@ -561,13 +561,13 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
const unsigned IOCTL_NOT_PRESENT = 0;
unsigned IOCTL_FIONBIO = FIONBIO;
-#if !SANITIZER_HAIKU
+# if !SANITIZER_HAIKU
unsigned IOCTL_FIOASYNC = FIOASYNC;
unsigned IOCTL_FIOCLEX = FIOCLEX;
unsigned IOCTL_FIOGETOWN = FIOGETOWN;
unsigned IOCTL_FIONCLEX = FIONCLEX;
unsigned IOCTL_FIOSETOWN = FIOSETOWN;
-#endif
+# endif
unsigned IOCTL_SIOCADDMULTI = SIOCADDMULTI;
unsigned IOCTL_SIOCATMARK = SIOCATMARK;
unsigned IOCTL_SIOCDELMULTI = SIOCDELMULTI;
@@ -589,14 +589,14 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
unsigned IOCTL_SIOCSIFNETMASK = SIOCSIFNETMASK;
unsigned IOCTL_SIOCSPGRP = SIOCSPGRP;
-#if !SANITIZER_HAIKU
+# if !SANITIZER_HAIKU
unsigned IOCTL_TIOCCONS = TIOCCONS;
unsigned IOCTL_TIOCGETD = TIOCGETD;
unsigned IOCTL_TIOCNOTTY = TIOCNOTTY;
unsigned IOCTL_TIOCPKT = TIOCPKT;
unsigned IOCTL_TIOCSETD = TIOCSETD;
unsigned IOCTL_TIOCSTI = TIOCSTI;
-#endif
+# endif
unsigned IOCTL_TIOCEXCL = TIOCEXCL;
unsigned IOCTL_TIOCGPGRP = TIOCGPGRP;
@@ -1118,11 +1118,11 @@ COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
CHECK_SIZE_AND_OFFSET(dirent, d_ino);
#if SANITIZER_APPLE
CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
-#elif SANITIZER_FREEBSD || SANITIZER_HAIKU
+# elif SANITIZER_FREEBSD || SANITIZER_HAIKU
// There is no 'd_off' field on FreeBSD.
-#else
+# else
CHECK_SIZE_AND_OFFSET(dirent, d_off);
-#endif
+# endif
CHECK_SIZE_AND_OFFSET(dirent, d_reclen);
#if SANITIZER_GLIBC
@@ -1134,9 +1134,9 @@ CHECK_SIZE_AND_OFFSET(dirent64, d_reclen);
CHECK_TYPE_SIZE(ifconf);
CHECK_SIZE_AND_OFFSET(ifconf, ifc_len);
-#if !SANITIZER_HAIKU
+# if !SANITIZER_HAIKU
CHECK_SIZE_AND_OFFSET(ifconf, ifc_ifcu);
-#endif
+# endif
CHECK_TYPE_SIZE(pollfd);
CHECK_SIZE_AND_OFFSET(pollfd, fd);
@@ -1191,7 +1191,7 @@ CHECK_TYPE_SIZE(__kernel_loff_t);
CHECK_TYPE_SIZE(__kernel_fd_set);
#endif
-#if !SANITIZER_ANDROID && !SANITIZER_HAIKU
+# if !SANITIZER_ANDROID && !SANITIZER_HAIKU
CHECK_TYPE_SIZE(wordexp_t);
CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc);
CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv);
@@ -1221,11 +1221,11 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_freq);
CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
#endif
-#if !SANITIZER_HAIKU
+# if !SANITIZER_HAIKU
CHECK_TYPE_SIZE(ether_addr);
-#endif
+# endif
-#if SANITIZER_GLIBC || SANITIZER_FREEBSD
+# if SANITIZER_GLIBC || SANITIZER_FREEBSD
CHECK_TYPE_SIZE(ipc_perm);
# if SANITIZER_FREEBSD
CHECK_SIZE_AND_OFFSET(ipc_perm, key);
@@ -1261,7 +1261,7 @@ CHECK_TYPE_SIZE(clock_t);
CHECK_TYPE_SIZE(clockid_t);
#endif
-#if !SANITIZER_ANDROID && !SANITIZER_HAIKU
+# if !SANITIZER_ANDROID && !SANITIZER_HAIKU
CHECK_TYPE_SIZE(ifaddrs);
CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next);
CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index 26de940f9..52f5a5ee5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -16,25 +16,25 @@
#if SANITIZER_LINUX || SANITIZER_APPLE || SANITIZER_HAIKU
-#include "sanitizer_internal_defs.h"
-#include "sanitizer_platform.h"
-#include "sanitizer_mallinfo.h"
-
-#if SANITIZER_APPLE
-#include <sys/cdefs.h>
-#if !__DARWIN_ONLY_64_BIT_INO_T
-#define SANITIZER_HAS_STAT64 1
-#define SANITIZER_HAS_STATFS64 1
-#else
-#define SANITIZER_HAS_STAT64 0
-#define SANITIZER_HAS_STATFS64 0
-#endif
-#elif SANITIZER_GLIBC || SANITIZER_ANDROID
-#define SANITIZER_HAS_STAT64 1
-#define SANITIZER_HAS_STATFS64 1
-#endif
+# include "sanitizer_internal_defs.h"
+# include "sanitizer_platform.h"
+# include "sanitizer_mallinfo.h"
+
+# if SANITIZER_APPLE
+# include <sys/cdefs.h>
+# if !__DARWIN_ONLY_64_BIT_INO_T
+# define SANITIZER_HAS_STAT64 1
+# define SANITIZER_HAS_STATFS64 1
+# else
+# define SANITIZER_HAS_STAT64 0
+# define SANITIZER_HAS_STATFS64 0
+# endif
+# elif SANITIZER_GLIBC || SANITIZER_ANDROID
+# define SANITIZER_HAS_STAT64 1
+# define SANITIZER_HAS_STATFS64 1
+# endif
-#if defined(__sparc__)
+# if defined(__sparc__)
// FIXME: This can't be included from tsan which does not support sparc yet.
#include "sanitizer_glibc_version.h"
#endif
@@ -366,7 +366,7 @@ struct __sanitizer_passwd {
long pw_change;
char *pw_class;
#endif
-#if !(SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32)) && !SANITIZER_HAIKU
+# if !(SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32)) && !SANITIZER_HAIKU
char *pw_gecos;
#endif
char *pw_dir;
@@ -374,9 +374,9 @@ struct __sanitizer_passwd {
#if SANITIZER_APPLE
long pw_expire;
#endif
-#if SANITIZER_HAIKU
+# if SANITIZER_HAIKU
char *pw_gecos;
-#endif
+# endif
};
struct __sanitizer_group {
@@ -436,11 +436,11 @@ struct __sanitizer_tm {
int tm_wday;
int tm_yday;
int tm_isdst;
-#if SANITIZER_HAIKU
+# if SANITIZER_HAIKU
int tm_gmtoff;
-#else
+# else
long int tm_gmtoff;
-#endif
+# endif
const char *tm_zone;
};
@@ -461,7 +461,7 @@ struct __sanitizer_file_handle {
};
#endif
-#if SANITIZER_APPLE || SANITIZER_HAIKU
+# if SANITIZER_APPLE || SANITIZER_HAIKU
struct __sanitizer_msghdr {
void *msg_name;
unsigned msg_namelen;
@@ -509,7 +509,7 @@ struct __sanitizer_dirent {
unsigned short d_reclen;
// more fields that we don't care about
};
-#elif SANITIZER_HAIKU
+# elif SANITIZER_HAIKU
struct __sanitizer_dirent {
int d_dev;
int d_pdev;
@@ -545,15 +545,15 @@ struct __sanitizer_dirent64 {
extern unsigned struct_sock_fprog_sz;
#endif
-#if SANITIZER_HAIKU
+# if SANITIZER_HAIKU
typedef int __sanitizer_clock_t;
-#elif defined(__x86_64__) && !defined(_LP64)
+# elif defined(__x86_64__) && !defined(_LP64)
typedef long long __sanitizer_clock_t;
-#else
+# else
typedef long __sanitizer_clock_t;
-#endif
+# endif
-#if SANITIZER_LINUX || SANITIZER_HAIKU
+# if SANITIZER_LINUX || SANITIZER_HAIKU
typedef int __sanitizer_clockid_t;
typedef unsigned long long __sanitizer_eventfd_t;
#endif
@@ -602,14 +602,14 @@ typedef unsigned long __sanitizer_sigset_t;
# endif
#elif SANITIZER_APPLE
typedef unsigned __sanitizer_sigset_t;
-#elif SANITIZER_HAIKU
+# elif SANITIZER_HAIKU
typedef unsigned long __sanitizer_sigset_t;
-#elif SANITIZER_LINUX
+# elif SANITIZER_LINUX
struct __sanitizer_sigset_t {
// The size is determined by looking at sizeof of real sigset_t on linux.
uptr val[128 / sizeof(uptr)];
};
-#endif
+# endif
struct __sanitizer_siginfo_pad {
#if SANITIZER_X32
@@ -799,7 +799,7 @@ struct __sanitizer_addrinfo {
int ai_family;
int ai_socktype;
int ai_protocol;
-#if SANITIZER_ANDROID || SANITIZER_APPLE || SANITIZER_HAIKU
+# if SANITIZER_ANDROID || SANITIZER_APPLE || SANITIZER_HAIKU
unsigned ai_addrlen;
char *ai_canonname;
void *ai_addr;
@@ -1148,14 +1148,14 @@ extern unsigned IOCTL_SIOCSIFMETRIC;
extern unsigned IOCTL_SIOCSIFMTU;
extern unsigned IOCTL_SIOCSIFNETMASK;
extern unsigned IOCTL_SIOCSPGRP;
-#if !SANITIZER_HAIKU
+# if !SANITIZER_HAIKU
extern unsigned IOCTL_TIOCCONS;
extern unsigned IOCTL_TIOCGETD;
extern unsigned IOCTL_TIOCNOTTY;
extern unsigned IOCTL_TIOCPKT;
extern unsigned IOCTL_TIOCSETD;
extern unsigned IOCTL_TIOCSTI;
-#endif
+# endif
extern unsigned IOCTL_TIOCEXCL;
extern unsigned IOCTL_TIOCGPGRP;
extern unsigned IOCTL_TIOCGWINSZ;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
index d713ddf84..18be13471 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
@@ -19,12 +19,12 @@
SANITIZER_APPLE || SANITIZER_SOLARIS || SANITIZER_HAIKU || \
SANITIZER_FUCHSIA
-#include "sanitizer_common.h"
-#include "sanitizer_internal_defs.h"
-#include "sanitizer_fuchsia.h"
-#include "sanitizer_linux.h"
-#include "sanitizer_mac.h"
-#include "sanitizer_mutex.h"
+# include "sanitizer_common.h"
+# include "sanitizer_internal_defs.h"
+# include "sanitizer_fuchsia.h"
+# include "sanitizer_linux.h"
+# include "sanitizer_mac.h"
+# include "sanitizer_mutex.h"
namespace __sanitizer {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_haiku.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_haiku.cpp
index 7a6062a57..530faeee4 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_haiku.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_haiku.cpp
@@ -12,11 +12,11 @@
#include "sanitizer_platform.h"
#if SANITIZER_HAIKU
+# include <kernel/OS.h>
+
# include "sanitizer_common.h"
# include "sanitizer_procmaps.h"
-# include <kernel/OS.h>
-
namespace __sanitizer {
void MemoryMappedSegment::AddAddressRanges(LoadedModule *module) {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp
index 3f6901a2e..db0f619c7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp
@@ -13,17 +13,17 @@
#include "sanitizer_platform.h"
#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \
SANITIZER_SOLARIS || SANITIZER_HAIKU
-#include "sanitizer_common.h"
-#include "sanitizer_stacktrace.h"
+# include "sanitizer_common.h"
+# include "sanitizer_stacktrace.h"
-#if SANITIZER_ANDROID
-#include <dlfcn.h> // for dlopen()
-#endif
+# if SANITIZER_ANDROID
+# include <dlfcn.h> // for dlopen()
+# endif
-#if SANITIZER_FREEBSD
-#define _GNU_SOURCE // to declare _Unwind_Backtrace() from <unwind.h>
-#endif
-#include <unwind.h>
+# if SANITIZER_FREEBSD
+# define _GNU_SOURCE // to declare _Unwind_Backtrace() from <unwind.h>
+# endif
+# include <unwind.h>
namespace __sanitizer {
|
3e57ad8
to
97116b9
Compare
@@ -569,6 +569,10 @@ append_list_if(COMPILER_RT_HAS_LIBC c SANITIZER_COMMON_LINK_LIBS) | |||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") | |||
list(APPEND SANITIZER_COMMON_LINK_LIBS zircon) | |||
endif() | |||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku") | |||
list(APPEND SANITIZER_COMMON_LINK_LIBS root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it link without ? surprised we need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libroot is the libc equivalent; as in there is no libc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I know but I was assuming it would be implictly linked to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without libroot it fails to build...
ld.lld: error: undefined symbol: environ
>>> referenced by sanitizer_linux.cpp:692 (/boot/home/llvm-brad/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:692)
>>> compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o:(__sanitizer::GetEnv(char const*))
>>> referenced by sanitizer_linux.cpp:765 (/boot/home/llvm-brad/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:765)
>>> compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o:(__sanitizer::GetEnviron())
ld.lld: error: undefined symbol: __libc_argv
>>> referenced by sanitizer_linux.cpp:764 (/boot/home/llvm-brad/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:764)
>>> compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o:(__sanitizer::GetArgv())
ld.lld: error: undefined symbol: sched_yield
>>> referenced by sanitizer_linux.cpp:826 (/boot/home/llvm-brad/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:826)
>>> compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o:(__sanitizer::FutexWait(__sanitizer::atomic_uint32_t*, unsigned int))
ld.lld: error: undefined symbol: sysconf
>>> referenced by sanitizer_linux.cpp:1279 (/boot/home/llvm-brad/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1279)
>>> compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o:(__sanitizer::GetPageSize())
>>> referenced by sanitizer_posix_libcdep.cpp:549 (/boot/home/llvm-brad/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp:549)
>>> compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_posix_libcdep.cpp.o:(__sanitizer::StartSubprocess(char const*, char const* const*, char const* const*, int, int, int))
ld.lld: error: undefined symbol: _get_next_image_info
>>> referenced by sanitizer_linux.cpp:1289 (/boot/home/llvm-brad/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1289)
>>> compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o:(__sanitizer::ReadBinaryName(char*, unsigned long))
>>> referenced by sanitizer_linux.cpp:1289 (/boot/home/llvm-brad/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1289)
>>> compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o:(__sanitizer::ReadLongProcessName(char*, unsigned long))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see good to know thx.
97116b9
to
48101b5
Compare
* origin/main: (287 commits) [Sema] On Windows, silence erroneous warning when building with MSVC [lldb][lldbp-dap] On Windoows, silence warnings when building with MSVC [lldb] Fix erroneous return value [compiler-rt] On Windows, silence warning when building with Clang ToT [clang][unittests] On Windows, silence warning when building with MSVC [lldb] On Windows, silence warning when building with Clang ToT [CIR] Make LLVM & OGCG variables match the same pattern (llvm#135427) [mlir][SMT] upstream `SMT` dialect (llvm#131480) [clang] fix serialization for SubstNonTypeTemplateParmPackExpr (llvm#135428) [flang][openacc] Allow if_present multiple times on host_data and update (llvm#135422) [flang][openacc] Allow finalize clause on exit data more than once (llvm#135415) [flang] IEEE_SCALB and SCALE - kind=2, kind=3 (llvm#135374) [-Wunsafe-buffer-usage] Add findUnsafePointers (llvm#135421) [compiler-rt][sanitizer] add Haiku support (llvm#134772) [cpp23] Remove usage of std::aligned_union<> in llvm (llvm#135146) [mlir][tosa] Add error_if checks for Mul Op (llvm#135075) [VPlan] Merge cases using getResultType in inferScalarType (NFC). [flang][runtime] Fix recently broken big-endian formatted integer input (llvm#135417) [AMDGPU][Verifier] Mark calls to entry functions as invalid in the IR verifier (llvm#134910) [llvm][Hexagon] Promote operand v2i1 to v2i32 (llvm#135409) ...
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/161/builds/5315 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2691 Here is the relevant piece of the build log for the reference
|
Co-authored-by: Jérôme Duval <[email protected]>
No description provided.