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