diff --git a/compiler-rt/test/asan/TestCases/debug_double_free.cpp b/compiler-rt/test/asan/TestCases/debug_double_free.cpp --- a/compiler-rt/test/asan/TestCases/debug_double_free.cpp +++ b/compiler-rt/test/asan/TestCases/debug_double_free.cpp @@ -37,7 +37,12 @@ return 0; } -void __asan_on_error() { +// Required for dyld macOS 12.0+ +#if (__APPLE__) +__attribute__((weak)) +#endif +extern "C" void +__asan_on_error() { int present = __asan_report_present(); void *addr = __asan_get_report_address(); const char *description = __asan_get_report_description(); diff --git a/compiler-rt/test/asan/TestCases/debug_report.cpp b/compiler-rt/test/asan/TestCases/debug_report.cpp --- a/compiler-rt/test/asan/TestCases/debug_report.cpp +++ b/compiler-rt/test/asan/TestCases/debug_report.cpp @@ -37,7 +37,12 @@ # define PTR_FMT "%p" #endif -void __asan_on_error() { +// Required for dyld macOS 12.0+ +#if (__APPLE__) +__attribute__((weak)) +#endif +extern "C" void +__asan_on_error() { int present = __asan_report_present(); void *pc = __asan_get_report_pc(); void *bp = __asan_get_report_bp(); diff --git a/compiler-rt/test/asan/TestCases/default_options.cpp b/compiler-rt/test/asan/TestCases/default_options.cpp --- a/compiler-rt/test/asan/TestCases/default_options.cpp +++ b/compiler-rt/test/asan/TestCases/default_options.cpp @@ -6,9 +6,13 @@ const char *kAsanDefaultOptions = "verbosity=1 help=1"; -extern "C" +// Required for dyld macOS 12.0+ +#if (__APPLE__) +__attribute__((weak)) +#endif __attribute__((no_sanitize_address)) -const char *__asan_default_options() { +extern "C" const char * +__asan_default_options() { // CHECK: Available flags for AddressSanitizer: return kAsanDefaultOptions; } diff --git a/compiler-rt/test/asan/TestCases/on_error_callback.cpp b/compiler-rt/test/asan/TestCases/on_error_callback.cpp --- a/compiler-rt/test/asan/TestCases/on_error_callback.cpp +++ b/compiler-rt/test/asan/TestCases/on_error_callback.cpp @@ -6,8 +6,12 @@ #include #include -extern "C" -void __asan_on_error() { +// Required for dyld macOS 12.0+ +#if (__APPLE__) +__attribute__((weak)) +#endif +extern "C" void +__asan_on_error() { fprintf(stderr, "__asan_on_error called\n"); fflush(stderr); } diff --git a/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp b/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp --- a/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp @@ -10,19 +10,21 @@ #include -extern "C" { -void __ubsan_get_current_report_data(const char **OutIssueKind, - const char **OutMessage, - const char **OutFilename, - unsigned *OutLine, unsigned *OutCol, - char **OutMemoryAddr); - -// Override the definition of __ubsan_on_report from the runtime, just for -// testing purposes. -void __ubsan_on_report(void) { +// Override __ubsan_on_report() from the runtime, just for testing purposes. +// Required for dyld macOS 12.0+ +#if (__APPLE__) +__attribute__((weak)) +#endif +extern "C" void +__ubsan_on_report(void) { + void __ubsan_get_current_report_data( + const char **OutIssueKind, const char **OutMessage, + const char **OutFilename, unsigned *OutLine, unsigned *OutCol, + char **OutMemoryAddr); const char *IssueKind, *Message, *Filename; unsigned Line, Col; char *Addr; + __ubsan_get_current_report_data(&IssueKind, &Message, &Filename, &Line, &Col, &Addr); @@ -33,7 +35,6 @@ (void)Addr; } -} int main() { char C = 3;