Merge changes Ib44cbea8,I9763caa0 into pi-dev
* changes:
Fix race in spawn.signal_stress test
Fix race in ld.config.txt tests
diff --git a/libdl/Android.bp b/libdl/Android.bp
index 082cdea..5998f9b 100644
--- a/libdl/Android.bp
+++ b/libdl/Android.bp
@@ -84,12 +84,7 @@
],
stl: "none",
- // NOTE: libdl needs __aeabi_unwind_cpp_pr0 from libgcc.a but libgcc.a needs a
- // few symbols from libc. Using --no-undefined here results in having to link
- // against libc creating a circular dependency which is removed and we end up
- // with missing symbols. Since this library is just a bunch of stubs, we set
- // LOCAL_ALLOW_UNDEFINED_SYMBOLS to remove --no-undefined from the linker flags.
- allow_undefined_symbols: true,
+ nocrt: true,
system_shared_libs: [],
// This is placeholder library the actual implementation is (currently)
diff --git a/libdl/libdl.cpp b/libdl/libdl.cpp
index c834088..402804e 100644
--- a/libdl/libdl.cpp
+++ b/libdl/libdl.cpp
@@ -214,4 +214,16 @@
return __loader_android_get_exported_namespace(name);
}
+#if defined(__arm__)
+// An arm32 unwinding table has an R_ARM_NONE relocation to
+// __aeabi_unwind_cpp_pr0. This shared library will never invoke the unwinder,
+// so it doesn't actually need the routine. Define a dummy version here,
+// because the real version calls libc functions (e.g. memcpy, abort), which
+// would create a dependency cycle with libc.so.
+__attribute__((visibility("hidden")))
+void __aeabi_unwind_cpp_pr0() {
+ __builtin_trap();
+}
+#endif
+
} // extern "C"
diff --git a/linker/Android.bp b/linker/Android.bp
index 2fcf369..7877a37 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -271,12 +271,7 @@
name: "ld-android",
defaults: ["linux_bionic_supported"],
- // NOTE: ld-android.so needs __aeabi_unwind_cpp_pr0 from libgcc.a but libgcc.a
- // needs a few symbols from libc. Using --no-undefined here results in having to
- // link against libc creating a circular dependency which is removed and we end
- // up with missing symbols. Since this library is just a bunch of stubs, we set
- // allow_undefined_symbols to remove --no-undefined from the linker flags.
- allow_undefined_symbols: true,
+ nocrt: true,
system_shared_libs: [],
sanitize: {
diff --git a/linker/ld_android.cpp b/linker/ld_android.cpp
index e2499b3..0528cd8 100644
--- a/linker/ld_android.cpp
+++ b/linker/ld_android.cpp
@@ -26,11 +26,10 @@
* SUCH DAMAGE.
*/
-#include <stdlib.h>
#include <sys/cdefs.h>
extern "C" void __internal_linker_error() {
- abort();
+ __builtin_trap();
}
__strong_alias(__loader_android_create_namespace, __internal_linker_error);
@@ -59,3 +58,14 @@
#endif
__strong_alias(rtld_db_dlactivity, __internal_linker_error);
+#if defined(__arm__)
+// An arm32 unwinding table has an R_ARM_NONE relocation to
+// __aeabi_unwind_cpp_pr0. This shared library will never invoke the unwinder,
+// so it doesn't actually need the routine. Define a dummy version here,
+// because the real version calls libc functions (e.g. memcpy, abort), which
+// would create a dependency cycle with libc.so.
+__attribute__((visibility("hidden")))
+extern "C" void __aeabi_unwind_cpp_pr0() {
+ __builtin_trap();
+}
+#endif
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 84f525d..7d9abf9 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -1438,7 +1438,8 @@
#define DT_ANDROID_RELA (llvm::ELF::DT_LOOS + 4)
template<typename ELFT>
-void validate_compatibility_of_native_library(const std::string& path, ELFT* elf) {
+void validate_compatibility_of_native_library(const std::string& soname,
+ const std::string& path, ELFT* elf) {
bool has_elf_hash = false;
bool has_android_rel = false;
bool has_rel = false;
@@ -1464,10 +1465,14 @@
ASSERT_TRUE(has_elf_hash) << path.c_str() << ": missing elf hash (DT_HASH)";
ASSERT_TRUE(!has_android_rel) << path.c_str() << ": has packed relocations";
- ASSERT_TRUE(has_rel) << path.c_str() << ": missing DT_REL/DT_RELA";
+ // libdl.so is simple enough that it might not have any relocations, so
+ // exempt it from the DT_REL/DT_RELA check.
+ if (soname != "libdl.so") {
+ ASSERT_TRUE(has_rel) << path.c_str() << ": missing DT_REL/DT_RELA";
+ }
}
-void validate_compatibility_of_native_library(const char* soname) {
+void validate_compatibility_of_native_library(const std::string& soname) {
// On the systems with emulation system libraries would be of different
// architecture. Try to use alternate paths first.
std::string path = std::string(ALTERNATE_PATH_TO_SYSTEM_LIB) + soname;
@@ -1487,7 +1492,7 @@
ASSERT_TRUE(elf != nullptr);
- validate_compatibility_of_native_library(path, elf);
+ validate_compatibility_of_native_library(soname, path, elf);
}
// This is a test for app compatibility workaround for arm apps
diff --git a/tests/libs/Android.build.dlext_testzip.mk b/tests/libs/Android.build.dlext_testzip.mk
index 4b6d099..62ed4c7 100644
--- a/tests/libs/Android.build.dlext_testzip.mk
+++ b/tests/libs/Android.build.dlext_testzip.mk
@@ -37,9 +37,10 @@
$(LOCAL_BUILT_MODULE): PRIVATE_SHARED_LIBS := $(my_shared_libs)
$(LOCAL_BUILT_MODULE): $(my_shared_libs) $(BIONIC_TESTS_ZIPALIGN)
@echo "Aligning zip: $@"
- $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)/libdir
- $(hide) cp $(PRIVATE_SHARED_LIBS) $(dir $@)/libdir
- $(hide) (cd $(dir $@) && touch empty_file.txt && zip -qrD0 $(notdir $@).unaligned empty_file.txt libdir/*.so)
+ $(hide) rm -rf $@.unaligned $@ $(dir $@)/zipdir && mkdir -p $(dir $@)/zipdir/libdir
+ $(hide) cp $(PRIVATE_SHARED_LIBS) $(dir $@)/zipdir/libdir
+ $(hide) touch $(dir $@)/zipdir/empty_file.txt
+ $(hide) (cd $(dir $@)/zipdir && zip -qrD0 ../$(notdir $@).unaligned .)
$(hide) $(BIONIC_TESTS_ZIPALIGN) 4096 $@.unaligned $@
include $(CLEAR_VARS)
@@ -64,13 +65,14 @@
$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_X := $(lib_x)
$(LOCAL_BUILT_MODULE) : $(lib_d) $(lib_a) $(lib_b) $(lib_c) $(lib_x) $(BIONIC_TESTS_ZIPALIGN)
@echo "Aligning zip: $@"
- $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)/libdir && \
- mkdir -p $(dir $@)/libdir/dt_runpath_a && mkdir -p $(dir $@)/libdir/dt_runpath_b_c_x
- $(hide) cp $(PRIVATE_LIB_D) $(dir $@)/libdir
- $(hide) cp $(PRIVATE_LIB_A) $(dir $@)/libdir/dt_runpath_a
- $(hide) cp $(PRIVATE_LIB_B) $(dir $@)/libdir/dt_runpath_b_c_x
- $(hide) cp $(PRIVATE_LIB_C) $(dir $@)/libdir/dt_runpath_b_c_x
- $(hide) cp $(PRIVATE_LIB_X) $(dir $@)/libdir/dt_runpath_b_c_x
- $(hide) (cd $(dir $@) && touch empty_file.txt && zip -qrD0 $(notdir $@).unaligned empty_file.txt libdir)
+ $(hide) rm -rf $@.unaligned $@ $(dir $@)/zipdir && mkdir -p $(dir $@)/zipdir/libdir && \
+ mkdir -p $(dir $@)/zipdir/libdir/dt_runpath_a && mkdir -p $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
+ $(hide) cp $(PRIVATE_LIB_D) $(dir $@)/zipdir/libdir
+ $(hide) cp $(PRIVATE_LIB_A) $(dir $@)/zipdir/libdir/dt_runpath_a
+ $(hide) cp $(PRIVATE_LIB_B) $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
+ $(hide) cp $(PRIVATE_LIB_C) $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
+ $(hide) cp $(PRIVATE_LIB_X) $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
+ $(hide) touch $(dir $@)/zipdir/empty_file.txt
+ $(hide) (cd $(dir $@)/zipdir && zip -qrD0 ../$(notdir $@).unaligned .)
$(hide) $(BIONIC_TESTS_ZIPALIGN) 4096 $@.unaligned $@