diff --git a/compiler-rt/include/sanitizer/hwasan_interface.h b/compiler-rt/include/sanitizer/hwasan_interface.h --- a/compiler-rt/include/sanitizer/hwasan_interface.h +++ b/compiler-rt/include/sanitizer/hwasan_interface.h @@ -13,6 +13,7 @@ #ifndef SANITIZER_HWASAN_INTERFACE_H #define SANITIZER_HWASAN_INTERFACE_H +#include #include #ifdef __cplusplus @@ -43,6 +44,14 @@ /// Set pointer tag. Previous tag is lost. void *__hwasan_tag_pointer(const volatile void *p, unsigned char tag); + // Register/unregister globals in an ELF library. The dynamic loader is + // required to call these when loading/unloading a library to prevent false + // positives from accesses to interposable globals in module constructors. + void __hwasan_library_loaded(ElfW(Addr) base, const ElfW(Phdr) * phdr, + ElfW(Half) phnum); + void __hwasan_library_unloaded(ElfW(Addr) base, const ElfW(Phdr) * phdr, + ElfW(Half) phnum); + // Set memory tag from the current SP address to the given address to zero. // This is meant to annotate longjmp and other non-local jumps. // This function needs to know the (almost) exact destination frame address; diff --git a/compiler-rt/lib/hwasan/hwasan.h b/compiler-rt/lib/hwasan/hwasan.h --- a/compiler-rt/lib/hwasan/hwasan.h +++ b/compiler-rt/lib/hwasan/hwasan.h @@ -14,6 +14,8 @@ #ifndef HWASAN_H #define HWASAN_H +#include + #include "hwasan_flags.h" #include "hwasan_interface_internal.h" #include "sanitizer_common/sanitizer_common.h" diff --git a/compiler-rt/lib/hwasan/hwasan_interface_internal.h b/compiler-rt/lib/hwasan/hwasan_interface_internal.h --- a/compiler-rt/lib/hwasan/hwasan_interface_internal.h +++ b/compiler-rt/lib/hwasan/hwasan_interface_internal.h @@ -14,9 +14,10 @@ #ifndef HWASAN_INTERFACE_INTERNAL_H #define HWASAN_INTERFACE_INTERNAL_H +#include + #include "sanitizer_common/sanitizer_internal_defs.h" #include "sanitizer_common/sanitizer_platform_limits_posix.h" -#include extern "C" { @@ -26,14 +27,6 @@ SANITIZER_INTERFACE_ATTRIBUTE void __hwasan_init(); -SANITIZER_INTERFACE_ATTRIBUTE -void __hwasan_library_loaded(ElfW(Addr) base, const ElfW(Phdr) * phdr, - ElfW(Half) phnum); - -SANITIZER_INTERFACE_ATTRIBUTE -void __hwasan_library_unloaded(ElfW(Addr) base, const ElfW(Phdr) * phdr, - ElfW(Half) phnum); - using __sanitizer::uptr; using __sanitizer::sptr; using __sanitizer::uu64;