loader: stop linking libdl/c/m into the loader
This is to prevent situations when libgcc.a calls into incorrect
implementation of dl_iterate_phdr.
Bug: http://b/27106625
Test: build && run bionic-unit-tests --getst_filter=dl*:Dl*
Change-Id: I4cba8c4a156f91f17ba3d95c39cb80f9b70c9d8f
diff --git a/libc/Android.bp b/libc/Android.bp
index 05df811..b1d077d 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1578,10 +1578,9 @@
// dynamic linker.
cc_library_static {
+ name: "libc_nomalloc",
+
defaults: ["libc_defaults"],
- srcs: [
- "bionic/dl_iterate_phdr_static.cpp",
- ],
arch: {
arm: {
@@ -1591,8 +1590,6 @@
cflags: ["-DLIBC_STATIC"],
- name: "libc_nomalloc",
-
whole_static_libs: [
"libc_common",
"libc_init_static",
diff --git a/linker/Android.bp b/linker/Android.bp
index 5745d73..1b7b5a7 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -103,6 +103,12 @@
cppflags: ["-Wold-style-cast"],
+ // we are going to link libc++_static manually because
+ // when stl is not set to "none" build system adds libdl
+ // to the list of static libraries which needs to be
+ // avoided in the case of building loader.
+ stl: "none",
+
// we don't want crtbegin.o (because we have begin.o), so unset it
// just for this module
nocrt: true,
@@ -114,6 +120,7 @@
"libbase",
"libz",
"liblog",
+ "libc++_static",
// Important: The liblinker_malloc should be the last library in the list
// to overwrite any other malloc implementations by other static libraries.