[compiler-rt] Library load interceptor does not need to be called for RTLD_NOLOAD (PR #190102)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 21:05:56 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Andrew Haberlandt (ndrewh)
<details>
<summary>Changes</summary>
`dlopen` can be called with `RTLD_NOLOAD` flag which will not load any new modules (and thus return NULL if the module is not already loaded). We can skip a lot of work in the interceptor if the user code is just trying to check if a module ia already loaded.
rdar://173907074
---
Full diff: https://github.com/llvm/llvm-project/pull/190102.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc (+5-2)
``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index b10ce7fa44afc..d68cac02e7eb6 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -33,6 +33,7 @@
// COMMON_INTERCEPTOR_STRERROR
//===----------------------------------------------------------------------===//
+#include <dlfcn.h>
#include <stdarg.h>
#include "interception/interception.h"
@@ -6537,8 +6538,10 @@ INTERCEPTOR(void*, dlopen, const char *filename, int flag) {
}
void *res = COMMON_INTERCEPTOR_DLOPEN(filename, flag);
- Symbolizer::GetOrInit()->InvalidateModuleList();
- COMMON_INTERCEPTOR_LIBRARY_LOADED(filename, res);
+ if ((flag & RTLD_NOLOAD) == 0) {
+ Symbolizer::GetOrInit()->InvalidateModuleList();
+ COMMON_INTERCEPTOR_LIBRARY_LOADED(filename, res);
+ }
return res;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/190102
More information about the llvm-commits
mailing list