[compiler-rt] 40dffef - [compiler-rt][hwasan] Do not call InitLoadedGlobals in __hwasan_init

Leonard Chan via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 11:47:25 PST 2022


Author: Leonard Chan
Date: 2022-11-09T19:47:05Z
New Revision: 40dffefa0e6557063763d814b824d721ce963e66

URL: https://github.com/llvm/llvm-project/commit/40dffefa0e6557063763d814b824d721ce963e66
DIFF: https://github.com/llvm/llvm-project/commit/40dffefa0e6557063763d814b824d721ce963e66.diff

LOG: [compiler-rt][hwasan] Do not call InitLoadedGlobals in __hwasan_init

Fuchsia's libc provides a new hook (__sanitizer_module_loaded) which calls
hwasan_library_loaded in the startup path which will register globals in
loaded modules.

Differential Revision: https://reviews.llvm.org/D137676

Added: 
    

Modified: 
    compiler-rt/lib/hwasan/hwasan.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp
index bb946c2ffe03a..9db4fb09409cb 100644
--- a/compiler-rt/lib/hwasan/hwasan.cpp
+++ b/compiler-rt/lib/hwasan/hwasan.cpp
@@ -340,7 +340,13 @@ __attribute__((constructor(0))) void __hwasan_init() {
   DisableCoreDumperIfNecessary();
 
   InitInstrumentation();
-  InitLoadedGlobals();
+  if constexpr (!SANITIZER_FUCHSIA) {
+    // Fuchsia's libc provides a hook (__sanitizer_module_loaded) that runs on
+    // the startup path which calls into __hwasan_library_loaded on all
+    // initially loaded modules, so explicitly registering the globals here
+    // isn't needed.
+    InitLoadedGlobals();
+  }
 
   // Needs to be called here because flags()->random_tags might not have been
   // initialized when InitInstrumentation() was called.


        


More information about the llvm-commits mailing list