Break libdl.so and ld-android.so's dependency on libc.so.
* Specify "nocrt: true" to avoid calling __cxa_finalize.
* Define a dummy __aeabi_unwind_cpp_pr0 for arm32.
Bug: b/62815515
Bug: b/73873002
Test: boot AOSP hikey960-userdebug
Test: run ndk_cxa_example in special /system/bin/debug namespace
Test: run Bionic unit tests
Change-Id: I59bcb100a2753286b59c51a47d7a183507219a07
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