[compiler-rt] fc4c872 - [Darwin][ASan] Fix "interceptor working?" check for DriverKit platform
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 6 15:50:50 PDT 2022
Author: Blue Gaston
Date: 2022-04-06T15:49:22-07:00
New Revision: fc4c872d8f1e0c3409ba1fbc4761ffc984c7fdbd
URL: https://github.com/llvm/llvm-project/commit/fc4c872d8f1e0c3409ba1fbc4761ffc984c7fdbd
DIFF: https://github.com/llvm/llvm-project/commit/fc4c872d8f1e0c3409ba1fbc4761ffc984c7fdbd.diff
LOG: [Darwin][ASan] Fix "interceptor working?" check for DriverKit platform
The previous check for interceptors used `pthread_create()` which is not
available on DriverKit. We need an intercepted symbol that satisfies
the following constraints:
- Symbol is available in DriverKit
- Symbol is provided by simulator runtime dylibs (`dlsym()` fails to
look up host-provided symbols)
`puts()` satisfies all of the above constraints.
rdar://87895539
Reviewed By: yln
Differential Revision: https://reviews.llvm.org/D123245
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index a95719b06a2c0..41b90b9f35802 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -1059,12 +1059,12 @@ void MaybeReexec() {
}
// Verify that interceptors really work. We'll use dlsym to locate
- // "pthread_create", if interceptors are working, it should really point to
- // "wrap_pthread_create" within our own dylib.
- Dl_info info_pthread_create;
- void *dlopen_addr = dlsym(RTLD_DEFAULT, "pthread_create");
- RAW_CHECK(dladdr(dlopen_addr, &info_pthread_create));
- if (internal_strcmp(info.dli_fname, info_pthread_create.dli_fname) != 0) {
+ // "puts", if interceptors are working, it should really point to
+ // "wrap_puts" within our own dylib.
+ Dl_info info_puts;
+ void *dlopen_addr = dlsym(RTLD_DEFAULT, "puts");
+ RAW_CHECK(dladdr(dlopen_addr, &info_puts));
+ if (internal_strcmp(info.dli_fname, info_puts.dli_fname) != 0) {
Report(
"ERROR: Interceptors are not working. This may be because %s is "
"loaded too late (e.g. via dlopen). Please launch the executable "
More information about the llvm-commits
mailing list