1//
2// libdl
3//
4cc_library {
5    name: "libdl",
6
7    defaults: ["linux_bionic_supported"],
8
9    // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
10    // libgcc.a are made static to libdl.so.  This in turn ensures that libraries that
11    // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so
12    // to provide those symbols, but will instead pull them from libgcc.a.  Specifically,
13    // we use this property to make sure libc.so has its own copy of the code from
14    // libgcc.a it uses.
15    //
16    // DO NOT REMOVE --exclude-libs!
17
18    ldflags: ["-Wl,--exclude-libs=libgcc.a"],
19
20    // for x86, exclude libgcc_eh.a for the same reasons as above
21    arch: {
22        arm: {
23            version_script: "libdl.arm.map",
24            ldflags: ["-Wl,--hash-style=both"],
25        },
26        arm64: {
27            version_script: "libdl.arm64.map",
28        },
29        mips: {
30            version_script: "libdl.mips.map",
31        },
32        mips64: {
33            version_script: "libdl.mips64.map",
34        },
35        x86: {
36            ldflags: [
37                "-Wl,--exclude-libs=libgcc_eh.a",
38                "-Wl,--hash-style=both",
39            ],
40            version_script: "libdl.x86.map",
41        },
42        x86_64: {
43            ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
44            version_script: "libdl.x86_64.map",
45        },
46    },
47    srcs: ["libdl.c", "libdl_cfi.cpp"],
48    cflags: [
49        "-Wall",
50        "-Wextra",
51        "-Wunused",
52        "-Werror",
53    ],
54    stl: "none",
55
56    // NOTE: libdl needs __aeabi_unwind_cpp_pr0 from libgcc.a but libgcc.a needs a
57    // few symbols from libc. Using --no-undefined here results in having to link
58    // against libc creating a circular dependency which is removed and we end up
59    // with missing symbols. Since this library is just a bunch of stubs, we set
60    // LOCAL_ALLOW_UNDEFINED_SYMBOLS to remove --no-undefined from the linker flags.
61    allow_undefined_symbols: true,
62    system_shared_libs: [],
63
64    // For private/CFIShadow.h.
65    include_dirs: ["bionic/libc"],
66
67    // This is placeholder library the actual implementation is (currently)
68    // provided by the linker.
69    shared_libs: [ "ld-android" ],
70
71    sanitize: {
72        never: true,
73    },
74}
75
76cc_library {
77    // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
78    // libgcc.a are made static to ld-android.so.  This in turn ensures that libraries that
79    // a) pull symbols from libgcc.a and b) depend on ld-android.so will not rely on ld-android.so
80    // to provide those symbols, but will instead pull them from libgcc.a.  Specifically,
81    // we use this property to make sure libc.so has its own copy of the code from
82    // libgcc.a it uses.
83    //
84    // DO NOT REMOVE --exclude-libs!
85
86    ldflags: ["-Wl,--exclude-libs=libgcc.a"],
87
88    // for x86, exclude libgcc_eh.a for the same reasons as above
89    arch: {
90        x86: {
91            ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
92        },
93        x86_64: {
94            ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
95        },
96    },
97    srcs: ["ld_android.c"],
98    cflags: [
99        "-Wall",
100        "-Wextra",
101        "-Wunused",
102        "-Werror",
103    ],
104    stl: "none",
105
106    name: "ld-android",
107    defaults: ["linux_bionic_supported"],
108
109    // NOTE: libdl needs __aeabi_unwind_cpp_pr0 from libgcc.a but libgcc.a needs a
110    // few symbols from libc. Using --no-undefined here results in having to link
111    // against libc creating a circular dependency which is removed and we end up
112    // with missing symbols. Since this library is just a bunch of stubs, we set
113    // LOCAL_ALLOW_UNDEFINED_SYMBOLS to remove --no-undefined from the linker flags.
114    allow_undefined_symbols: true,
115    system_shared_libs: [],
116
117    sanitize: {
118        never: true,
119    },
120}
121
122ndk_library {
123    name: "libdl",
124    symbol_file: "libdl.map.txt",
125    first_version: "9",
126}
127
128llndk_library {
129    name: "libdl",
130    symbol_file: "libdl.map.txt",
131}
132