Index: lib/asan/asan_interceptors.h =================================================================== --- lib/asan/asan_interceptors.h +++ lib/asan/asan_interceptors.h @@ -34,10 +34,10 @@ } // namespace __asan -// There is no general interception at all on Fuchsia. +// There is no general interception at all on Fuchsia and RTEMS. // Only the functions in asan_interceptors_memintrinsics.h are // really defined to replace libc functions. -#if !SANITIZER_FUCHSIA +#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS // Use macro to describe if specific function should be // intercepted on a given platform. Index: lib/asan/asan_interceptors.cc =================================================================== --- lib/asan/asan_interceptors.cc +++ lib/asan/asan_interceptors.cc @@ -24,10 +24,10 @@ #include "lsan/lsan_common.h" #include "sanitizer_common/sanitizer_libc.h" -// There is no general interception at all on Fuchsia. +// There is no general interception at all on Fuchsia and RTEMS. // Only the functions in asan_interceptors_memintrinsics.cc are // really defined to replace libc functions. -#if !SANITIZER_FUCHSIA +#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS #if SANITIZER_POSIX #include "sanitizer_common/sanitizer_posix.h" Index: lib/asan/asan_internal.h =================================================================== --- lib/asan/asan_internal.h +++ lib/asan/asan_internal.h @@ -36,7 +36,7 @@ // If set, values like allocator chunk size, as well as defaults for some flags // will be changed towards less memory overhead. #ifndef ASAN_LOW_MEMORY -# if SANITIZER_IOS || SANITIZER_ANDROID +# if SANITIZER_IOS || SANITIZER_ANDROID || SANITIZER_RTEMS # define ASAN_LOW_MEMORY 1 # else # define ASAN_LOW_MEMORY 0 @@ -78,7 +78,7 @@ // asan_malloc_linux.cc / asan_malloc_mac.cc void ReplaceSystemMalloc(); -// asan_linux.cc / asan_mac.cc / asan_win.cc +// asan_linux.cc / asan_mac.cc / asan_rtems.cc / asan_win.cc uptr FindDynamicShadowStart(); void *AsanDoesNotSupportStaticLinkage(); void AsanCheckDynamicRTPrereqs(); Index: lib/asan/asan_poisoning.h =================================================================== --- lib/asan/asan_poisoning.h +++ lib/asan/asan_poisoning.h @@ -51,6 +51,9 @@ // changed at all. It doesn't currently have an efficient means // to zero a bunch of pages, but maybe we should add one. SANITIZER_FUCHSIA == 1 || + // RTEMS doesn't have have pages, let alone a fast way to zero + // them, so default to memset. + SANITIZER_RTEMS == 1 || shadow_end - shadow_beg < common_flags()->clear_shadow_mmap_threshold) { REAL(memset)((void*)shadow_beg, value, shadow_end - shadow_beg); } else { Index: lib/asan/asan_shadow_setup.cc =================================================================== --- lib/asan/asan_shadow_setup.cc +++ lib/asan/asan_shadow_setup.cc @@ -14,8 +14,9 @@ #include "sanitizer_common/sanitizer_platform.h" -// asan_fuchsia.cc has its own InitializeShadowMemory implementation. -#if !SANITIZER_FUCHSIA +// asan_fuchsia.cc and asan_rtems.cc have their own +// InitializeShadowMemory implementation. +#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS #include "asan_internal.h" #include "asan_mapping.h" @@ -162,4 +163,4 @@ } // namespace __asan -#endif // !SANITIZER_FUCHSIA +#endif // !SANITIZER_FUCHSIA && !SANITIZER_RTEMS Index: lib/asan/asan_thread.cc =================================================================== --- lib/asan/asan_thread.cc +++ lib/asan/asan_thread.cc @@ -236,9 +236,10 @@ &local); } -// Fuchsia doesn't use ThreadStart. -// asan_fuchsia.c defines CreateMainThread and SetThreadStackAndTls. -#if !SANITIZER_FUCHSIA +// Fuchsia and RTEMS don't use ThreadStart. +// asan_fuchsia.c/asan_rtems.c define CreateMainThread and +// SetThreadStackAndTls. +#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS thread_return_t AsanThread::ThreadStart( tid_t os_id, atomic_uintptr_t *signal_thread_is_registered) { @@ -298,7 +299,7 @@ CHECK(AddrIsInStack((uptr)&local)); } -#endif // !SANITIZER_FUCHSIA +#endif // !SANITIZER_FUCHSIA && !SANITIZER_RTEMS void AsanThread::ClearShadowForThreadStackAndTLS() { PoisonShadow(stack_bottom_, stack_top_ - stack_bottom_, 0); Index: lib/interception/interception.h =================================================================== --- lib/interception/interception.h +++ lib/interception/interception.h @@ -19,7 +19,7 @@ #if !SANITIZER_LINUX && !SANITIZER_FREEBSD && !SANITIZER_MAC && \ !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_WINDOWS && \ - !SANITIZER_FUCHSIA && !SANITIZER_SOLARIS + !SANITIZER_FUCHSIA && !SANITIZER_RTEMS && !SANITIZER_SOLARIS # error "Interception doesn't work on this operating system." #endif @@ -130,6 +130,11 @@ extern "C" ret_type func(__VA_ARGS__); # define DECLARE_WRAPPER_WINAPI(ret_type, func, ...) \ extern "C" __declspec(dllimport) ret_type __stdcall func(__VA_ARGS__); +#elif SANITIZER_RTEMS +# define WRAP(x) x +# define WRAPPER_NAME(x) #x +# define INTERCEPTOR_ATTRIBUTE +# define DECLARE_WRAPPER(ret_type, func, ...) #elif SANITIZER_FREEBSD || SANITIZER_NETBSD # define WRAP(x) __interceptor_ ## x # define WRAPPER_NAME(x) "__interceptor_" #x @@ -157,6 +162,10 @@ # define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default"))) # define REAL(x) __unsanitized_##x # define DECLARE_REAL(ret_type, func, ...) +#elif SANITIZER_RTEMS +# define REAL(x) __real_ ## x +# define DECLARE_REAL(ret_type, func, ...) \ + extern "C" ret_type REAL(func)(__VA_ARGS__); #elif !SANITIZER_MAC # define PTR_TO_REAL(x) real_##x # define REAL(x) __interception::PTR_TO_REAL(x) @@ -175,7 +184,7 @@ # define ASSIGN_REAL(x, y) #endif // SANITIZER_MAC -#if !SANITIZER_FUCHSIA +#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS #define DECLARE_REAL_AND_INTERCEPTOR(ret_type, func, ...) \ DECLARE_REAL(ret_type, func, __VA_ARGS__) \ extern "C" ret_type WRAP(func)(__VA_ARGS__); @@ -187,7 +196,7 @@ // macros does its job. In exceptional cases you may need to call REAL(foo) // without defining INTERCEPTOR(..., foo, ...). For example, if you override // foo with an interceptor for other function. -#if !SANITIZER_MAC && !SANITIZER_FUCHSIA +#if !SANITIZER_MAC && !SANITIZER_FUCHSIA && !SANITIZER_RTEMS # define DEFINE_REAL(ret_type, func, ...) \ typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__); \ namespace __interception { \ Index: lib/sanitizer_common/sanitizer_errno.h =================================================================== --- lib/sanitizer_common/sanitizer_errno.h +++ lib/sanitizer_common/sanitizer_errno.h @@ -24,7 +24,8 @@ #if SANITIZER_FREEBSD || SANITIZER_MAC # define __errno_location __error -#elif SANITIZER_ANDROID || SANITIZER_NETBSD || SANITIZER_OPENBSD +#elif SANITIZER_ANDROID || SANITIZER_NETBSD || SANITIZER_OPENBSD || \ + SANITIZER_RTEMS # define __errno_location __errno #elif SANITIZER_SOLARIS # define __errno_location ___errno Index: lib/sanitizer_common/sanitizer_platform.h =================================================================== --- lib/sanitizer_common/sanitizer_platform.h +++ lib/sanitizer_common/sanitizer_platform.h @@ -15,7 +15,8 @@ #if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \ !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(_WIN32) && \ - !defined(__Fuchsia__) && !(defined(__sun__) && defined(__svr4__)) + !defined(__Fuchsia__) && !defined(__rtems__) && \ + !(defined(__sun__) && defined(__svr4__)) # error "This operating system is not supported" #endif Index: lib/sanitizer_common/sanitizer_platform_interceptors.h =================================================================== --- lib/sanitizer_common/sanitizer_platform_interceptors.h +++ lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -28,7 +28,7 @@ # define SI_WINDOWS 1 #endif -#if (SI_POSIX != 0) == (SI_WINDOWS != 0) && !SANITIZER_FUCHSIA +#if SI_WINDOWS && SI_POSIX # error "Windows is not POSIX!" #endif Index: lib/sanitizer_common/sanitizer_stacktrace.h =================================================================== --- lib/sanitizer_common/sanitizer_stacktrace.h +++ lib/sanitizer_common/sanitizer_stacktrace.h @@ -32,7 +32,7 @@ // Fast unwind is the only option on Mac for now; we will need to // revisit this macro when slow unwind works on Mac, see // https://github.com/google/sanitizers/issues/137 -#if SANITIZER_MAC || SANITIZER_OPENBSD +#if SANITIZER_MAC || SANITIZER_OPENBSD || SANITIZER_RTEMS # define SANITIZER_CAN_SLOW_UNWIND 0 #else # define SANITIZER_CAN_SLOW_UNWIND 1 Index: lib/sanitizer_common/sanitizer_stacktrace_printer.cc =================================================================== --- lib/sanitizer_common/sanitizer_stacktrace_printer.cc +++ lib/sanitizer_common/sanitizer_stacktrace_printer.cc @@ -17,8 +17,8 @@ namespace __sanitizer { -// sanitizer_symbolizer_fuchsia.cc implements these differently for Fuchsia. -#if !SANITIZER_FUCHSIA +// sanitizer_symbolizer_markup.cc implements these differently. +#if !SANITIZER_SYMBOLIZER_MARKUP static const char *StripFunctionName(const char *function, const char *prefix) { if (!function) return nullptr; @@ -228,7 +228,7 @@ } } -#endif // !SANITIZER_FUCHSIA +#endif // !SANITIZER_SYMBOLIZER_MARKUP void RenderSourceLocation(InternalScopedString *buffer, const char *file, int line, int column, bool vs_style, Index: lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc +++ lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc @@ -26,8 +26,8 @@ return symbolizer_; } -// See sanitizer_symbolizer_fuchsia.cc. -#if !SANITIZER_FUCHSIA +// See sanitizer_symbolizer_markup.cc. +#if !SANITIZER_SYMBOLIZER_MARKUP const char *ExtractToken(const char *str, const char *delims, char **result) { uptr prefix_len = internal_strcspn(str, delims); @@ -489,6 +489,6 @@ return true; } -#endif // !SANITIZER_FUCHSIA +#endif // !SANITIZER_SYMBOLIZER_MARKUP } // namespace __sanitizer Index: lib/sanitizer_common/sanitizer_symbolizer_report.cc =================================================================== --- lib/sanitizer_common/sanitizer_symbolizer_report.cc +++ lib/sanitizer_common/sanitizer_symbolizer_report.cc @@ -117,7 +117,7 @@ #endif } -#if !SANITIZER_FUCHSIA && !SANITIZER_GO +#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS && !SANITIZER_GO void StartReportDeadlySignal() { // Write the first message using fd=2, just in case. // It may actually fail to write in case stderr is closed. Index: lib/ubsan/ubsan_platform.h =================================================================== --- lib/ubsan/ubsan_platform.h +++ lib/ubsan/ubsan_platform.h @@ -17,7 +17,7 @@ #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || \ defined(__NetBSD__) || defined(__OpenBSD__) || \ (defined(__sun__) && defined(__svr4__)) || \ - defined(_WIN32) || defined(__Fuchsia__) + defined(_WIN32) || defined(__Fuchsia__) || defined(__rtems__) # define CAN_SANITIZE_UB 1 #else # define CAN_SANITIZE_UB 0