Merge "Cleanup: __libc_init_AT_SECURE, auxv, sysinfo"
diff --git a/libc/Android.bp b/libc/Android.bp
index c08df9d..4c5b0b3 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -76,6 +76,9 @@
},
native_coverage: false,
recovery_available: true,
+
+ // TODO(ivanlozano): Remove after b/118321713
+ xom: false,
}
// ANDROIDMK TRANSLATION ERROR: unsupported directive
diff --git a/libc/bionic/malloc_common.cpp b/libc/bionic/malloc_common.cpp
index 8d8d420..9a80767 100644
--- a/libc/bionic/malloc_common.cpp
+++ b/libc/bionic/malloc_common.cpp
@@ -366,12 +366,6 @@
}
static bool InitMallocFunctions(void* impl_handler, MallocDispatch* table, const char* prefix) {
- // We initialize free first to prevent the following situation:
- // Heapprofd's MallocMalloc is installed, and an allocation is observed
- // and logged to the heap dump. The corresponding free happens before
- // heapprofd's MallocFree is installed, and is not logged in the heap
- // dump. This leads to the allocation wrongly being active in the heap
- // dump indefinitely.
if (!InitMallocFunction<MallocFree>(impl_handler, &table->free, prefix, "free")) {
return false;
}
@@ -572,6 +566,16 @@
}
atomic_store(&g_heapprofd_init_func, init_func);
+ // We assign free first explicitly to prevent the case where we observe a
+ // alloc, but miss the corresponding free because of initialization order.
+ //
+ // This is safer than relying on the declaration order inside
+ // MallocDispatch at the cost of an extra atomic pointer write on
+ // initialization.
+ atomic_store(&globals->malloc_dispatch.free, dispatch_table.free);
+ // The struct gets assigned elementwise and each of the elements is an
+ // _Atomic. Assigning to an _Atomic is an atomic_store operation.
+ // The assignment is done in declaration order.
globals->malloc_dispatch = dispatch_table;
info_log("%s: malloc %s enabled", getprogname(), prefix);
@@ -679,7 +683,7 @@
extern "C" void InstallInitHeapprofdHook(int) {
if (!atomic_exchange(&g_heapprofd_init_in_progress, true)) {
__libc_globals.mutate([](libc_globals* globals) {
- globals->malloc_dispatch.malloc = InitHeapprofdHook;
+ atomic_store(&globals->malloc_dispatch.malloc, InitHeapprofdHook);
});
}
}
diff --git a/libm/Android.bp b/libm/Android.bp
index 6d55967..e4ba20d 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -514,6 +514,9 @@
integer_overflow: false,
},
stl: "none",
+
+ // TODO(ivanlozano): Remove after b/118321713
+ xom: false,
}
ndk_library {
diff --git a/linker/Android.bp b/linker/Android.bp
index 8ef540c..a9907ca 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -289,6 +289,7 @@
},
},
compile_multilib: "both",
+ xom: false,
}
cc_library {