1//
2// libdl
3//
4cc_library_static {
5    name: "libdl_static",
6    defaults: ["linux_bionic_supported"],
7    ramdisk_available: true,
8    recovery_available: true,
9    native_bridge_supported: true,
10
11    srcs: [
12        "libdl.cpp",
13        "libdl_cfi.cpp",
14    ],
15
16    cflags: [
17        "-Wall",
18        "-Wextra",
19        "-Wunused",
20        "-Werror",
21    ],
22
23    // For private/CFIShadow.h.
24    include_dirs: ["bionic/libc"],
25
26    stl: "none",
27    system_shared_libs: [],
28    header_libs: ["libc_headers"],
29    export_header_lib_headers: ["libc_headers"],
30
31    sanitize: {
32        never: true,
33    },
34}
35
36cc_library {
37    name: "libdl",
38    ramdisk_available: true,
39    recovery_available: true,
40    native_bridge_supported: true,
41    static_ndk_lib: true,
42
43    defaults: ["linux_bionic_supported"],
44
45    // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
46    // libgcc.a are made static to libdl.so.  This in turn ensures that libraries that
47    // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so
48    // to provide those symbols, but will instead pull them from libgcc.a.  Specifically,
49    // we use this property to make sure libc.so has its own copy of the code from
50    // libgcc.a it uses.
51    //
52    // DO NOT REMOVE --exclude-libs!
53
54    ldflags: [
55        "-Wl,--exclude-libs=libgcc.a",
56        "-Wl,--exclude-libs=libgcc_stripped.a",
57        "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
58        "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
59        "-Wl,--exclude-libs=libclang_rt.builtins-x86-android.a",
60        "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
61    ],
62
63    // for x86, exclude libgcc_eh.a for the same reasons as above
64    arch: {
65        arm: {
66            version_script: ":libdl.arm.map",
67            pack_relocations: false,
68            ldflags: ["-Wl,--hash-style=both"],
69        },
70        arm64: {
71            version_script: ":libdl.arm64.map",
72        },
73        x86: {
74            pack_relocations: false,
75            ldflags: [
76                "-Wl,--exclude-libs=libgcc_eh.a",
77                "-Wl,--hash-style=both",
78            ],
79            version_script: ":libdl.x86.map",
80        },
81        x86_64: {
82            ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
83            version_script: ":libdl.x86_64.map",
84        },
85    },
86    shared: {
87        whole_static_libs: ["libdl_static"],
88    },
89    static: {
90        srcs: ["libdl_static.cpp"],
91    },
92    cflags: [
93        "-Wall",
94        "-Wextra",
95        "-Wunused",
96        "-Werror",
97    ],
98    stl: "none",
99
100    nocrt: true,
101    system_shared_libs: [],
102    header_libs: ["libc_headers"],
103
104    // Opt out of native_coverage when opting out of system_shared_libs
105    native_coverage: false,
106
107    // This is placeholder library the actual implementation is (currently)
108    // provided by the linker.
109    shared_libs: ["ld-android"],
110
111    sanitize: {
112        never: true,
113    },
114
115    stubs: {
116        symbol_file: "libdl.map.txt",
117        versions: [
118            "29",
119            "10000",
120        ],
121    },
122
123    apex_available: [
124        "//apex_available:platform",
125        "com.android.runtime",
126    ],
127}
128
129cc_library {
130    name: "libdl_android",
131
132    defaults: ["linux_bionic_supported"],
133    ramdisk_available: true,
134    recovery_available: true,
135    native_bridge_supported: true,
136
137    // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
138    // libgcc.a are made static to libdl.so.  This in turn ensures that libraries that
139    // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so
140    // to provide those symbols, but will instead pull them from libgcc.a.  Specifically,
141    // we use this property to make sure libc.so has its own copy of the code from
142    // libgcc.a it uses.
143    //
144    // DO NOT REMOVE --exclude-libs!
145
146    ldflags: [
147        "-Wl,--exclude-libs=libgcc.a",
148        "-Wl,--exclude-libs=libgcc_stripped.a",
149        "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
150        "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
151        "-Wl,--exclude-libs=libclang_rt.builtins-x86-android.a",
152        "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
153    ],
154
155    // for x86, exclude libgcc_eh.a for the same reasons as above
156    arch: {
157        x86: {
158            ldflags: [
159                "-Wl,--exclude-libs=libgcc_eh.a",
160            ],
161        },
162        x86_64: {
163            ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
164        },
165    },
166
167    srcs: [ "libdl_android.cpp" ],
168    version_script: "libdl_android.map.txt",
169
170    cflags: [
171        "-Wall",
172        "-Wextra",
173        "-Wunused",
174        "-Werror",
175    ],
176
177    stl: "none",
178
179    nocrt: true,
180    system_shared_libs: [],
181    header_libs: ["libc_headers"],
182
183    // Opt out of native_coverage when opting out of system_shared_libs
184    native_coverage: false,
185
186    // This is placeholder library the actual implementation is (currently)
187    // provided by the linker.
188    shared_libs: ["ld-android"],
189
190    sanitize: {
191        never: true,
192    },
193
194    stubs: {
195        symbol_file: "libdl_android.map.txt",
196        versions: ["10000"],
197    },
198
199    apex_available: [
200        "//apex_available:platform",
201        "com.android.runtime",
202    ],
203}
204
205ndk_library {
206    name: "libdl",
207    native_bridge_supported: true,
208    symbol_file: "libdl.map.txt",
209    first_version: "9",
210}
211
212llndk_library {
213    name: "libdl",
214    native_bridge_supported: true,
215    symbol_file: "libdl.map.txt",
216}
217
218genrule {
219    name: "libdl.arm.map",
220    out: ["libdl.arm.map"],
221    srcs: ["libdl.map.txt"],
222    tool_files: [":bionic-generate-version-script"],
223    cmd: "$(location :bionic-generate-version-script) arm $(in) $(out)",
224}
225
226genrule {
227    name: "libdl.arm64.map",
228    out: ["libdl.arm64.map"],
229    srcs: ["libdl.map.txt"],
230    tool_files: [":bionic-generate-version-script"],
231    cmd: "$(location :bionic-generate-version-script) arm64 $(in) $(out)",
232}
233
234genrule {
235    name: "libdl.x86.map",
236    out: ["libdl.x86.map"],
237    srcs: ["libdl.map.txt"],
238    tool_files: [":bionic-generate-version-script"],
239    cmd: "$(location :bionic-generate-version-script) x86 $(in) $(out)",
240}
241
242genrule {
243    name: "libdl.x86_64.map",
244    out: ["libdl.x86_64.map"],
245    srcs: ["libdl.map.txt"],
246    tool_files: [":bionic-generate-version-script"],
247    cmd: "$(location :bionic-generate-version-script) x86_64 $(in) $(out)",
248}
249