Merge "Update to remove direct include of jemalloc_new."
diff --git a/libc/include/elf.h b/libc/include/elf.h
index bebaea1..a319abb 100644
--- a/libc/include/elf.h
+++ b/libc/include/elf.h
@@ -248,12 +248,6 @@
#define DT_RELR 36
#define DT_RELRENT 37
-/* Android compressed rel/rela sections */
-#define DT_ANDROID_REL (DT_LOOS + 2)
-#define DT_ANDROID_RELSZ (DT_LOOS + 3)
-#define DT_ANDROID_RELA (DT_LOOS + 4)
-#define DT_ANDROID_RELASZ (DT_LOOS + 5)
-
#define DT_GNU_HASH 0x6ffffef5
#define DT_TLSDESC_PLT 0x6ffffef6
#define DT_TLSDESC_GOT 0x6ffffef7
@@ -535,12 +529,28 @@
/*
* Experimental support for SHT_RELR sections. For details, see proposal
* at https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg.
+ *
* This was eventually replaced by SHT_RELR and DT_RELR (which are identical
* other than their different constants), but those constants are only
- * supported by the OS starting at API level 30.
+ * supported by the OS in API levels >= 30.
*/
#define SHT_ANDROID_RELR 0x6fffff00
#define DT_ANDROID_RELR 0x6fffe000
#define DT_ANDROID_RELRSZ 0x6fffe001
#define DT_ANDROID_RELRENT 0x6fffe003
#define DT_ANDROID_RELRCOUNT 0x6fffe005
+
+/*
+ * Android compressed REL/RELA sections. These were generated by the relocation
+ * packer in old versions of Android, and can be generated directly by lld
+ * with https://reviews.llvm.org/D39152.
+ *
+ * This was replaced by SHT_ANDROID_RELR in API level 28 (but is supported
+ * in all API levels >= 23).
+ */
+#define SHT_ANDROID_REL 0x60000001
+#define SHT_ANDROID_RELA 0x60000002
+#define DT_ANDROID_REL 0x6000000f // DT_LOOS + 2
+#define DT_ANDROID_RELSZ 0x60000010 // DT_LOOS + 3
+#define DT_ANDROID_RELA 0x60000011 // DT_LOOS + 4
+#define DT_ANDROID_RELASZ 0x60000012 // DT_LOOS + 5
diff --git a/tests/Android.bp b/tests/Android.bp
index 2bfe42b..c254839 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -613,8 +613,10 @@
"libdl_preempt_test_2",
"libdl_test_df_1_global",
"libgnu-hash-table-library",
- "librelr-new",
- "librelr-old",
+ "librelocations-ANDROID_RELR",
+ "librelocations-ANDROID_REL",
+ "librelocations-RELR",
+ "librelocations-fat",
"libsysv-hash-table-library",
"libtestshared",
"libtest_atexit",
diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp
index 2b963c7..ed60e8e 100644
--- a/tests/dl_test.cpp
+++ b/tests/dl_test.cpp
@@ -347,3 +347,52 @@
eth.Run([&]() { execve(helper.c_str(), eth.GetArgs(), eth.GetEnv()); }, EXIT_FAILURE, error_message.c_str());
#endif
}
+
+static void RelocationsTest(const char* lib, const char* expectation) {
+#if defined(__BIONIC__)
+ // Does readelf think the .so file looks right?
+ const std::string path = GetTestlibRoot() + "/" + lib;
+ ExecTestHelper eth;
+ eth.SetArgs({ "readelf", "-SW", path.c_str(), nullptr });
+ eth.Run([&]() { execvpe("readelf", eth.GetArgs(), eth.GetEnv()); }, 0, nullptr);
+ ASSERT_TRUE(eth.GetOutput().find(expectation) != std::string::npos) << eth.GetOutput();
+
+ // Can we load it?
+ void* handle = dlopen(lib, RTLD_NOW);
+ ASSERT_TRUE(handle != nullptr) << dlerror();
+#else
+ UNUSED(lib);
+ UNUSED(expectation);
+ GTEST_SKIP() << "test is not supported on glibc";
+#endif
+}
+
+TEST(dl, relocations_RELR) {
+ RelocationsTest("librelocations-RELR.so",
+ ".relr.dyn RELR");
+}
+
+TEST(dl, relocations_ANDROID_RELR) {
+ RelocationsTest("librelocations-ANDROID_RELR.so",
+ ".relr.dyn ANDROID_RELR");
+}
+
+TEST(dl, relocations_ANDROID_REL) {
+ RelocationsTest("librelocations-ANDROID_REL.so",
+#if __LP64__
+ ".rela.dyn ANDROID_RELA"
+#else
+ ".rel.dyn ANDROID_REL"
+#endif
+ );
+}
+
+TEST(dl, relocations_fat) {
+ RelocationsTest("librelocations-fat.so",
+#if __LP64__
+ ".rela.dyn RELA"
+#else
+ ".rel.dyn REL"
+#endif
+ );
+}
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index e36883a..d815dba 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -1765,13 +1765,3 @@
}
#endif
-
-TEST(dlfcn, relr_old) {
- void* handle = dlopen("librelr-old.so", RTLD_NOW);
- ASSERT_TRUE(handle != nullptr) << dlerror();
-}
-
-TEST(dlfcn, relr_new) {
- void* handle = dlopen("librelr-new.so", RTLD_NOW);
- ASSERT_TRUE(handle != nullptr) << dlerror();
-}
diff --git a/tests/libs/Android.bp b/tests/libs/Android.bp
index 29224f5..9be85c8 100644
--- a/tests/libs/Android.bp
+++ b/tests/libs/Android.bp
@@ -1500,15 +1500,21 @@
// -----------------------------------------------------------------------------
-// Check that we support both the old and new SHT_RELR constants.
+// Check that we support all kinds of relocations: regular, "relocation packer",
+// and both the old and new SHT_RELR constants.
// -----------------------------------------------------------------------------
+// This is what got standardized for SHT_RELR.
cc_test_library {
- name: "librelr-new",
- ldflags: ["-Wl,--no-use-android-relr-tags"],
+ name: "librelocations-RELR",
+ ldflags: [
+ "-Wl,--pack-dyn-relocs=relr",
+ "-Wl,--no-use-android-relr-tags",
+ ],
host_supported: false,
defaults: ["bionic_testlib_defaults"],
- srcs: ["relr.cpp"],
+ srcs: ["relocations.cpp"],
+
// Hack to ensure we're using llvm-objcopy because our binutils prebuilt
// only supports the old numbers (http://b/141010852).
strip: {
@@ -1516,10 +1522,32 @@
},
}
+// This is the same encoding as SHT_RELR, but using OS-specific constants.
cc_test_library {
- name: "librelr-old",
- ldflags: ["-Wl,--use-android-relr-tags"],
+ name: "librelocations-ANDROID_RELR",
+ ldflags: [
+ "-Wl,--pack-dyn-relocs=relr",
+ "-Wl,--use-android-relr-tags",
+ ],
host_supported: false,
defaults: ["bionic_testlib_defaults"],
- srcs: ["relr.cpp"],
+ srcs: ["relocations.cpp"],
+}
+
+// This is the old relocation packer encoding (DT_ANDROID_REL/DT_ANDROID_RELA).
+cc_test_library {
+ name: "librelocations-ANDROID_REL",
+ ldflags: ["-Wl,--pack-dyn-relocs=android"],
+ host_supported: false,
+ defaults: ["bionic_testlib_defaults"],
+ srcs: ["relocations.cpp"],
+}
+
+// This is not packed at all.
+cc_test_library {
+ name: "librelocations-fat",
+ ldflags: ["-Wl,--pack-dyn-relocs=none"],
+ host_supported: false,
+ defaults: ["bionic_testlib_defaults"],
+ srcs: ["relocations.cpp"],
}
diff --git a/tests/libs/relr.cpp b/tests/libs/relocations.cpp
similarity index 95%
rename from tests/libs/relr.cpp
rename to tests/libs/relocations.cpp
index 7ea07b5..3c9d604 100644
--- a/tests/libs/relr.cpp
+++ b/tests/libs/relocations.cpp
@@ -26,6 +26,6 @@
* SUCH DAMAGE.
*/
-extern "C" const char* relr() {
- return "relr";
+extern "C" const char* function() {
+ return "relocations";
}
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index 20e6f16..ef2f895 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -36,14 +36,20 @@
#include <android-base/file.h>
-#include "platform/bionic/malloc.h"
-#include "private/bionic_config.h"
#include "utils.h"
#if defined(__BIONIC__)
+
+#include "platform/bionic/malloc.h"
+#include "platform/bionic/reserved_signals.h"
+#include "private/bionic_config.h"
+
#define HAVE_REALLOCARRAY 1
+
#else
+
#define HAVE_REALLOCARRAY __GLIBC_PREREQ(2, 26)
+
#endif
TEST(malloc, malloc_std) {
@@ -1082,7 +1088,7 @@
// heapprofd handler.
union sigval signal_value;
signal_value.sival_int = 0;
- ASSERT_EQ(0, sigqueue(getpid(), __SIGRTMIN + 4, signal_value));
+ ASSERT_EQ(0, sigqueue(getpid(), BIONIC_SIGNAL_PROFILER, signal_value));
size_t num_successful = 0;
for (size_t i = 0; i < kNumThreads; i++) {