Merge "Enable BTI in bionic linker"
diff --git a/libc/Android.bp b/libc/Android.bp
index a761e3b..61d99ac 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1726,7 +1726,7 @@
versions: [
"29",
"R",
- "10000",
+ "current",
],
},
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index 833fa59..a237254 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -170,6 +170,16 @@
* Available since API level 28.
*/
#define M_PURGE (-101)
+/*
+ * mallopt() option for per-thread memory initialization tuning.
+ * The value argument should be one of:
+ * 1: Disable automatic heap initialization and, where possible, memory tagging,
+ * on this thread.
+ * 0: Normal behavior.
+ *
+ * Available since API level 31.
+ */
+#define M_THREAD_DISABLE_MEM_INIT (-103)
/**
* mallopt() option to set the maximum number of items in the secondary
* cache of the scudo allocator.
diff --git a/libc/malloc_hooks/Android.bp b/libc/malloc_hooks/Android.bp
index 77b523e..487f3fb 100644
--- a/libc/malloc_hooks/Android.bp
+++ b/libc/malloc_hooks/Android.bp
@@ -70,6 +70,7 @@
cflags: [
"-Wall",
"-Werror",
+ "-O1", // FIXME: http://b/169206016 - issues with aligned_alloc and -O2
],
test_suites: ["general-tests"],
}
diff --git a/libdl/Android.bp b/libdl/Android.bp
index 6a3a82e..d843c44 100644
--- a/libdl/Android.bp
+++ b/libdl/Android.bp
@@ -116,7 +116,7 @@
symbol_file: "libdl.map.txt",
versions: [
"29",
- "10000",
+ "current",
],
},
@@ -193,7 +193,7 @@
stubs: {
symbol_file: "libdl_android.map.txt",
- versions: ["10000"],
+ versions: ["current"],
},
apex_available: [
diff --git a/libm/Android.bp b/libm/Android.bp
index 6a348e1..318a4bc 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -498,7 +498,7 @@
symbol_file: "libm.map.txt",
versions: [
"29",
- "10000",
+ "current",
],
},
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index 55bd149..d692cf9 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -84,6 +84,24 @@
free(ptr);
}
+TEST(malloc, calloc_mem_init_disabled) {
+#if defined(__BIONIC__)
+ // calloc should still zero memory if mem-init is disabled.
+ // With jemalloc the mallopts will fail but that shouldn't affect the
+ // execution of the test.
+ mallopt(M_THREAD_DISABLE_MEM_INIT, 1);
+ size_t alloc_len = 100;
+ char *ptr = reinterpret_cast<char*>(calloc(1, alloc_len));
+ for (size_t i = 0; i < alloc_len; i++) {
+ ASSERT_EQ(0, ptr[i]);
+ }
+ free(ptr);
+ mallopt(M_THREAD_DISABLE_MEM_INIT, 0);
+#else
+ GTEST_SKIP() << "bionic-only test";
+#endif
+}
+
TEST(malloc, calloc_illegal) {
SKIP_WITH_HWASAN;
errno = 0;
diff --git a/tools/versioner/src/Driver.cpp b/tools/versioner/src/Driver.cpp
index 184c3d4..adf93c3 100644
--- a/tools/versioner/src/Driver.cpp
+++ b/tools/versioner/src/Driver.cpp
@@ -42,6 +42,7 @@
#include <llvm/ADT/SmallVector.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/Option/Option.h>
+#include <llvm/Support/Host.h>
#include <llvm/Support/VirtualFileSystem.h>
#include "Arch.h"