diff options
author | Leonard Chan <leonardchan@google.com> | 2023-05-17 18:45:44 +0000 |
---|---|---|
committer | Leonard Chan <leonardchan@google.com> | 2023-05-17 18:45:44 +0000 |
commit | dc3069dadf6fd4eece82936fe913dc8310a24cd0 (patch) | |
tree | fb3e63d90270c66276692ab5e4bf83fb8923839a | |
parent | 0e66105a9260d80d58215c0c627f35e950c35b99 (diff) | |
download | llvm-dc3069dadf6fd4eece82936fe913dc8310a24cd0.tar.gz |
[NFC][hwasan][Fuchsia] Instead wrap contents of InitLoadedGlobals with if constexpr (!SANITIZER_FUCHSIA)
This prevents spamming the build log with unused InitLoadedGlobals when building fuchsia runtimes.
Differential Revision: https://reviews.llvm.org/D150737
-rw-r--r-- | compiler-rt/lib/hwasan/hwasan.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp index 238fcc4d6185..b64e52cbb95f 100644 --- a/compiler-rt/lib/hwasan/hwasan.cpp +++ b/compiler-rt/lib/hwasan/hwasan.cpp @@ -290,14 +290,20 @@ static bool InitializeSingleGlobal(const hwasan_global &global) { } static void InitLoadedGlobals() { - dl_iterate_phdr( - [](dl_phdr_info *info, size_t /* size */, void * /* data */) -> int { - for (const hwasan_global &global : HwasanGlobalsFor( - info->dlpi_addr, info->dlpi_phdr, info->dlpi_phnum)) - InitializeSingleGlobal(global); - return 0; - }, - nullptr); + // 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. + if constexpr (!SANITIZER_FUCHSIA) { + dl_iterate_phdr( + [](dl_phdr_info *info, size_t /* size */, void * /* data */) -> int { + for (const hwasan_global &global : HwasanGlobalsFor( + info->dlpi_addr, info->dlpi_phdr, info->dlpi_phnum)) + InitializeSingleGlobal(global); + return 0; + }, + nullptr); + } } // Prepare to run instrumented code on the main thread. @@ -364,13 +370,7 @@ __attribute__((constructor(0))) void __hwasan_init() { DisableCoreDumperIfNecessary(); InitInstrumentation(); - 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(); - } + InitLoadedGlobals(); // Needs to be called here because flags()->random_tags might not have been // initialized when InitInstrumentation() was called. |