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