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 @@ -43,6 +43,26 @@ /// Set pointer tag. Previous tag is lost. void *__hwasan_tag_pointer(const volatile void *p, unsigned char tag); + // Register/unregister globals in a loaded module. The dynamic loader is + // required to call these when loading/unloading a module to prevent false + // positives from accesses to interposable globals in module constructors. + // + // In particular, the loaded hook needs to be called: + // - After the module has been fully loaded + // - After relocations have been resolved + // - Before module constructors have been run + // + void __hwasan_library_loaded(uintptr_t base, const void *phdr, + size_t phnum); + + // The unloaded hook needs to be called: + // - After the module's code will no longer run (which also means after + // destructors) + // - Before the module's segments have been unmapped. + // + void __hwasan_library_unloaded(uintptr_t base, const void *phdr, + size_t 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;