Move platform-private symbols out of libdl.so
Symbols not intended to be accessible from apps are moved to libdl_android.so
Test: bionic-unit-tests
Bug: http://b/129387775
Change-Id: Ib8ba6147a20cf56550c9a008f66570a2d419565a
(cherry picked from commit 2d6be9a751685b4c307632bf27e8c100310ad500)
diff --git a/libdl/Android.bp b/libdl/Android.bp
index 2e171d6..a41aa2d 100644
--- a/libdl/Android.bp
+++ b/libdl/Android.bp
@@ -110,6 +110,72 @@
},
}
+cc_library {
+ name: "libdl_android",
+
+ defaults: ["linux_bionic_supported"],
+
+ // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
+ // libgcc.a are made static to libdl.so. This in turn ensures that libraries that
+ // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so
+ // to provide those symbols, but will instead pull them from libgcc.a. Specifically,
+ // we use this property to make sure libc.so has its own copy of the code from
+ // libgcc.a it uses.
+ //
+ // DO NOT REMOVE --exclude-libs!
+
+ ldflags: [
+ "-Wl,--exclude-libs=libgcc.a",
+ "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
+ "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
+ "-Wl,--exclude-libs=libclang_rt.builtins-x86-android.a",
+ "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
+ ],
+
+ // for x86, exclude libgcc_eh.a for the same reasons as above
+ arch: {
+ x86: {
+ ldflags: [
+ "-Wl,--exclude-libs=libgcc_eh.a",
+ ],
+ },
+ x86_64: {
+ ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
+ },
+ },
+
+ srcs: [ "libdl_android.cpp" ],
+ version_script: "libdl_android.map.txt",
+
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Wunused",
+ "-Werror",
+ ],
+
+ stl: "none",
+
+ nocrt: true,
+ system_shared_libs: [],
+
+ // Opt out of native_coverage when opting out of system_shared_libs
+ native_coverage: false,
+
+ // This is placeholder library the actual implementation is (currently)
+ // provided by the linker.
+ shared_libs: ["ld-android"],
+
+ sanitize: {
+ never: true,
+ },
+
+ stubs: {
+ symbol_file: "libdl_android.map.txt",
+ versions: ["10000"],
+ },
+}
+
ndk_library {
name: "libdl",
symbol_file: "libdl.map.txt",