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/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.