[HWASan] [MTE] disable MTE for HWASan binaries
Bug: 389848256
Test: atest hwasan_test with persist.arm64.memtag.default=sync
Test: atest bionic-unit-tests[-static]
Change-Id: I871932af1ed763e3b7d5f580052a009d5aa02e7d
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index 85e742c..0c962ff 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -167,7 +167,7 @@
}
__attribute__((no_sanitize("memtag"))) __noreturn static void __real_libc_init(
- KernelArgumentBlock& args, void* raw_args, void (*onexit)(void) __unused,
+ KernelArgumentBlock& args, void* raw_args __unused, void (*onexit)(void) __unused,
int (*slingshot)(int, char**, char**), structors_array_t const* const structors,
bionic_tcb* temp_tcb) {
BIONIC_STOP_UNWIND;
@@ -180,10 +180,12 @@
layout_static_tls(args);
__libc_init_main_thread_final();
__libc_init_common();
+#if !__has_feature(hwaddress_sanitizer)
__libc_init_mte(/*memtag_dynamic_entries=*/nullptr,
reinterpret_cast<ElfW(Phdr)*>(getauxval(AT_PHDR)), getauxval(AT_PHNUM),
/*load_bias = */ 0);
__libc_init_mte_stack(/*stack_top = */ raw_args);
+#endif
__libc_init_scudo();
__libc_globals.mutate(__libc_init_malloc);
__libc_init_profiling_handlers();
@@ -205,8 +207,9 @@
if (structors->fini_array_count > 0) {
__cxa_atexit(call_fini_array, const_cast<structors_array_t*>(structors), nullptr);
}
-
+#if !__has_feature(hwaddress_sanitizer)
__libc_init_mte_late();
+#endif
exit(slingshot(args.argc, args.argv, args.envp));
}