aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-02-02 08:39:13 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-02-02 08:39:13 +0000
commit2e19e10a45cd40ba5c2fd8c8b581cbebb7a4e800 (patch)
tree4be17fed9e546672cafa61c0fded487f2beb2bd2
parentf7e721cdc99ded867ea55b07e2b46e8b9b563f7d (diff)
parente38981339aa28d3004376e6085923bc5e39b0db8 (diff)
downloadbionic-ndk-r25-beta1.tar.gz
Snap for 8141157 from e38981339aa28d3004376e6085923bc5e39b0db8 to ndk-r25-releasendk-r25-beta1
Change-Id: I0f203a7ce8b505c849a48b2191b0db6377d9d80b
-rw-r--r--libc/bionic/libc_init_dynamic.cpp16
-rw-r--r--libc/malloc_hooks/tests/malloc_hooks_tests.cpp4
2 files changed, 13 insertions, 7 deletions
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index 4625fa1d4..24efbf5e7 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -93,6 +93,15 @@ static void __libc_preinit_impl() {
__libc_init_common();
__libc_init_scudo();
+#if __has_feature(hwaddress_sanitizer)
+ // Notify the HWASan runtime library whenever a library is loaded or unloaded
+ // so that it can update its shadow memory.
+ // This has to happen before _libc_init_malloc which might dlopen to load
+ // profiler libraries.
+ __libc_shared_globals()->load_hook = __hwasan_library_loaded;
+ __libc_shared_globals()->unload_hook = __hwasan_library_unloaded;
+#endif
+
// Hooks for various libraries to let them know that we're starting up.
__libc_globals.mutate(__libc_init_malloc);
@@ -101,13 +110,6 @@ static void __libc_preinit_impl() {
__libc_init_fork_handler();
-#if __has_feature(hwaddress_sanitizer)
- // Notify the HWASan runtime library whenever a library is loaded or unloaded
- // so that it can update its shadow memory.
- __libc_shared_globals()->load_hook = __hwasan_library_loaded;
- __libc_shared_globals()->unload_hook = __hwasan_library_unloaded;
-#endif
-
__libc_shared_globals()->set_target_sdk_version_hook = __libc_set_target_sdk_version;
netdClientInit();
diff --git a/libc/malloc_hooks/tests/malloc_hooks_tests.cpp b/libc/malloc_hooks/tests/malloc_hooks_tests.cpp
index 18587819a..ca064c2fe 100644
--- a/libc/malloc_hooks/tests/malloc_hooks_tests.cpp
+++ b/libc/malloc_hooks/tests/malloc_hooks_tests.cpp
@@ -350,6 +350,9 @@ TEST_F(MallocHooksTest, aligned_alloc_hook_error) {
RunTest("*.DISABLED_aligned_alloc_hook_error");
}
+// Allow deliberate call with non-power-of-two alignment in test code.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnon-power-of-two-alignment"
TEST_F(MallocHooksTest, DISABLED_aligned_alloc_hook_error) {
Init();
ASSERT_TRUE(__memalign_hook != nullptr);
@@ -365,6 +368,7 @@ TEST_F(MallocHooksTest, DISABLED_aligned_alloc_hook_error) {
EXPECT_FALSE(void_arg_ != nullptr)
<< "The memalign hook was called with a nullptr with an error.";
}
+#pragma clang diagnostic pop
#if !defined(__LP64__)
TEST_F(MallocHooksTest, pvalloc_hook) {