blob: 55daf2202601e97bba1c5316f283dbed09efb1cf [file] [log] [blame]
Ryan Prichard80e40f02019-10-31 19:54:46 -07001// ========================================================
2// linker_wrapper - Linux Bionic (on the host)
3// ========================================================
Colin Cross97f0aef2016-07-14 16:05:46 -07004
Dan Willemsen7ccc50d2017-09-18 21:28:14 -07005// This is used for bionic on (host) Linux to bootstrap our linker embedded into
6// a binary.
7//
8// Host bionic binaries do not have a PT_INTERP section, instead this gets
9// embedded as the entry point, and the linker is embedded as ELF sections in
10// each binary. There's a linker script that sets all of that up (generated by
11// extract_linker), and defines the extern symbols used in this file.
Bob Badouraa7d8352021-02-19 13:06:22 -080012package {
Aditya Choudharyd9d37c02024-02-02 13:57:12 +000013 default_team: "trendy_team_native_tools_libraries",
Bob Badouraa7d8352021-02-19 13:06:22 -080014 default_applicable_licenses: ["bionic_linker_license"],
15}
16
17license {
18 name: "bionic_linker_license",
19 visibility: [":__subpackages__"],
20 license_kinds: [
21 "SPDX-license-identifier-BSD",
22 ],
23 license_text: [
24 "NOTICE",
25 ],
26}
27
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070028cc_object {
29 name: "linker_wrapper",
30 host_supported: true,
31 device_supported: false,
Colin Crossda446cc2022-03-08 15:07:57 -080032 enabled: false,
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070033 target: {
Elliott Hughesd50a1de2018-02-05 17:30:57 -080034 linux_bionic: {
35 enabled: true,
36 },
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070037 },
38
39 cflags: [
40 "-fno-stack-protector",
41 "-Wstrict-overflow=5",
42 "-fvisibility=hidden",
43 "-Wall",
44 "-Wextra",
45 "-Wno-unused",
46 "-Werror",
47 ],
48
49 srcs: [
50 "linker_wrapper.cpp",
51 ],
52 arch: {
Jiyong Park3b47d602020-09-18 16:15:53 +090053 arm64: {
Colin Crossa0a591a2021-06-11 12:46:45 -070054 srcs: ["arch/arm64/linker_wrapper_begin.S"],
Jiyong Park3b47d602020-09-18 16:15:53 +090055 },
Elliott Hughes3e4f6032022-10-22 03:54:59 +000056 riscv64: {
57 srcs: ["arch/riscv64/linker_wrapper_begin.S"],
58 },
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070059 x86_64: {
Colin Crossa0a591a2021-06-11 12:46:45 -070060 srcs: ["arch/x86_64/linker_wrapper_begin.S"],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070061 },
62 },
63
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010064 header_libs: ["libc_headers"],
65
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070066 // We need to access Bionic private headers in the linker.
67 include_dirs: ["bionic/libc"],
68}
69
Ryan Prichard80e40f02019-10-31 19:54:46 -070070// ========================================================
71// linker default configuration
72// ========================================================
73
74// Configuration for the linker binary and any of its static libraries.
75cc_defaults {
76 name: "linker_defaults",
77 arch: {
78 arm: {
79 cflags: ["-D__work_around_b_24465209__"],
80 },
81 x86: {
82 cflags: ["-D__work_around_b_24465209__"],
83 },
84 },
85
86 cflags: [
87 "-fno-stack-protector",
88 "-Wstrict-overflow=5",
89 "-fvisibility=hidden",
90 "-Wall",
91 "-Wextra",
92 "-Wunused",
93 "-Werror",
94 ],
95
96 // TODO: split out the asflags.
97 asflags: [
98 "-fno-stack-protector",
99 "-Wstrict-overflow=5",
100 "-fvisibility=hidden",
101 "-Wall",
102 "-Wextra",
103 "-Wunused",
104 "-Werror",
105 ],
106
107 product_variables: {
108 debuggable: {
109 cppflags: ["-DUSE_LD_CONFIG_FILE"],
110 },
111 },
112
113 cppflags: ["-Wold-style-cast"],
114
115 static_libs: [
116 "libziparchive",
117 "libbase",
118 "libz",
Kalesh Singh4084b552024-03-13 13:35:49 -0700119 "libprocinfo", // For procinfo::MappedFileSize()
Ryan Prichard80e40f02019-10-31 19:54:46 -0700120
121 "libasync_safe",
122
Jiyong Park7157dfb2022-08-19 13:09:18 +0900123 "liblog_for_runtime_apex",
Ryan Prichard80e40f02019-10-31 19:54:46 -0700124 ],
125
126 // We need to access Bionic private headers in the linker.
127 include_dirs: ["bionic/libc"],
128}
129
130// ========================================================
131// linker components
132// ========================================================
133
134// Enable a module on all targets the linker runs on (ordinary Android targets, Linux Bionic, and
135// native bridge implementations).
136cc_defaults {
137 name: "linker_all_targets",
138 defaults: ["linux_bionic_supported"],
139 recovery_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -0700140 vendor_ramdisk_available: true,
Ryan Prichard80e40f02019-10-31 19:54:46 -0700141 native_bridge_supported: true,
142}
143
144cc_library_static {
Ryan Prichard249757b2019-11-01 17:18:28 -0700145 name: "liblinker_main",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000146 defaults: [
147 "linker_defaults",
148 "linker_all_targets",
149 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700150 srcs: ["linker_main.cpp"],
151
152 // Ensure that the compiler won't insert string function calls before ifuncs are resolved.
153 cflags: ["-ffreestanding"],
Spandan Das0a6cfe92024-01-04 18:06:50 +0000154 apex_available: [
155 "com.android.runtime",
156 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700157}
158
159cc_library_static {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700160 name: "liblinker_malloc",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000161 defaults: [
162 "linker_defaults",
163 "linker_all_targets",
164 ],
Ryan Prichard80e40f02019-10-31 19:54:46 -0700165 srcs: ["linker_memory.cpp"],
Spandan Das0a6cfe92024-01-04 18:06:50 +0000166 apex_available: [
167 "com.android.runtime",
168 ],
Ryan Prichard80e40f02019-10-31 19:54:46 -0700169}
170
171cc_library_static {
172 name: "liblinker_debuggerd_stub",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000173 defaults: [
174 "linker_defaults",
175 "linker_all_targets",
176 ],
Ryan Prichard80e40f02019-10-31 19:54:46 -0700177 srcs: ["linker_debuggerd_stub.cpp"],
178}
179
180// ========================================================
181// template for the linker binary
182// ========================================================
183
dimitryb8b3a762018-09-25 12:31:11 +0200184filegroup {
185 name: "linker_sources",
Colin Cross97f0aef2016-07-14 16:05:46 -0700186 srcs: [
187 "dlfcn.cpp",
188 "linker.cpp",
Elliott Hughes838dbac2023-08-22 14:07:48 -0700189 "linker_auxv.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700190 "linker_block_allocator.cpp",
Dimitry Ivanov769b33f2016-07-21 11:33:40 -0700191 "linker_dlwarning.cpp",
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700192 "linker_cfi.cpp",
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800193 "linker_config.cpp",
Ryan Prichard551565e2019-12-23 16:03:14 -0800194 "linker_debug.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700195 "linker_gdb_support.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -0700196 "linker_globals.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700197 "linker_libc_support.c",
Dimitry Ivanov451909d2017-01-26 16:52:59 -0800198 "linker_libcxx_support.cpp",
Dimitry Ivanovb943f302016-08-03 16:00:10 -0700199 "linker_namespaces.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700200 "linker_logger.cpp",
201 "linker_mapped_file_fragment.cpp",
Tamas Petz8d55d182020-02-24 14:15:25 +0100202 "linker_note_gnu_property.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700203 "linker_phdr.cpp",
Ryan Prichard339ecef2020-01-02 16:36:06 -0800204 "linker_relocate.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700205 "linker_sdk_versions.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -0700206 "linker_soinfo.cpp",
Collin Fijalkovich47d27aa2021-03-24 10:17:39 -0700207 "linker_transparent_hugepage_support.cpp",
Ryan Prichard45d13492019-01-03 02:51:30 -0800208 "linker_tls.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700209 "linker_utils.cpp",
210 "rt.cpp",
211 ],
dimitryb8b3a762018-09-25 12:31:11 +0200212}
Colin Cross97f0aef2016-07-14 16:05:46 -0700213
dimitryb8b3a762018-09-25 12:31:11 +0200214filegroup {
215 name: "linker_sources_arm",
216 srcs: [
217 "arch/arm/begin.S",
Ryan Prichard129f7a12019-12-23 16:45:47 -0800218 "arch/arm_neon/linker_gnu_hash_neon.cpp",
dimitryb8b3a762018-09-25 12:31:11 +0200219 ],
220}
221
222filegroup {
223 name: "linker_sources_arm64",
224 srcs: [
225 "arch/arm64/begin.S",
Ryan Prichardffaae702019-01-23 17:47:10 -0800226 "arch/arm64/tlsdesc_resolver.S",
Ryan Prichard129f7a12019-12-23 16:45:47 -0800227 "arch/arm_neon/linker_gnu_hash_neon.cpp",
dimitryb8b3a762018-09-25 12:31:11 +0200228 ],
229}
230
231filegroup {
Elliott Hughes3e4f6032022-10-22 03:54:59 +0000232 name: "linker_sources_riscv64",
233 srcs: [
234 "arch/riscv64/begin.S",
235 ],
236}
237
238filegroup {
dimitryb8b3a762018-09-25 12:31:11 +0200239 name: "linker_sources_x86",
240 srcs: [
241 "arch/x86/begin.S",
242 ],
243}
244
245filegroup {
246 name: "linker_sources_x86_64",
247 srcs: [
248 "arch/x86_64/begin.S",
249 ],
250}
251
dimitryb8b3a762018-09-25 12:31:11 +0200252cc_defaults {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700253 name: "linker_version_script_overlay",
254 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000255 arm: {
256 version_script: "linker.arm.map",
257 },
258 arm64: {
259 version_script: "linker.generic.map",
260 },
261 riscv64: {
262 version_script: "linker.generic.map",
263 },
264 x86: {
265 version_script: "linker.generic.map",
266 },
267 x86_64: {
268 version_script: "linker.generic.map",
269 },
Ryan Prichard80e40f02019-10-31 19:54:46 -0700270 },
271}
272
273// A template for the linker binary. May be inherited by native bridge implementations.
274cc_defaults {
275 name: "linker_bin_template",
276 defaults: ["linker_defaults"],
277
278 srcs: [":linker_sources"],
279
Colin Cross97f0aef2016-07-14 16:05:46 -0700280 arch: {
281 arm: {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700282 srcs: [":linker_sources_arm"],
Christopher Ferrisd37df2b2022-08-11 17:27:50 -0700283
284 // Arm 32 bit does not produce complete exidx unwind information
285 // so keep the .debug_frame which is relatively small and does
286 // include needed unwind information.
287 // See b/242162222 for details.
288 strip: {
289 keep_symbols_and_debug_frame: true,
290 },
Ryan Prichard80e40f02019-10-31 19:54:46 -0700291 },
292 arm64: {
293 srcs: [":linker_sources_arm64"],
Christopher Ferrisd37df2b2022-08-11 17:27:50 -0700294
295 // Leave the symbols in the shared library so that stack unwinders can produce
296 // meaningful name resolution.
297 strip: {
298 keep_symbols: true,
299 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700300 },
Elliott Hughes3e4f6032022-10-22 03:54:59 +0000301 riscv64: {
302 srcs: [":linker_sources_riscv64"],
303
304 // Leave the symbols in the shared library so that stack unwinders can produce
305 // meaningful name resolution.
306 strip: {
307 keep_symbols: true,
308 },
309 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700310 x86: {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700311 srcs: [":linker_sources_x86"],
Christopher Ferrisd37df2b2022-08-11 17:27:50 -0700312
313 // Leave the symbols in the shared library so that stack unwinders can produce
314 // meaningful name resolution.
315 strip: {
316 keep_symbols: true,
317 },
Ryan Prichard80e40f02019-10-31 19:54:46 -0700318 },
319 x86_64: {
320 srcs: [":linker_sources_x86_64"],
Christopher Ferrisd37df2b2022-08-11 17:27:50 -0700321
322 // Leave the symbols in the shared library so that stack unwinders can produce
323 // meaningful name resolution.
324 strip: {
325 keep_symbols: true,
326 },
Ryan Prichard80e40f02019-10-31 19:54:46 -0700327 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700328 },
329
Ryan Prichard80e40f02019-10-31 19:54:46 -0700330 // -shared is used to overwrite the -Bstatic and -static flags triggered by enabling
331 // static_executable. This dynamic linker is actually a shared object linked with static
332 // libraries.
Colin Cross97f0aef2016-07-14 16:05:46 -0700333 ldflags: [
334 "-shared",
335 "-Wl,-Bsymbolic",
336 "-Wl,--exclude-libs,ALL",
dimitry8e8c2c02018-01-04 12:08:32 +0100337 "-Wl,-soname,ld-android.so",
Colin Cross97f0aef2016-07-14 16:05:46 -0700338 ],
339
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800340 // we are going to link libc++_static manually because
341 // when stl is not set to "none" build system adds libdl
342 // to the list of static libraries which needs to be
343 // avoided in the case of building loader.
344 stl: "none",
345
Colin Cross97f0aef2016-07-14 16:05:46 -0700346 // we don't want crtbegin.o (because we have begin.o), so unset it
347 // just for this module
348 nocrt: true,
349
dimitryb8b3a762018-09-25 12:31:11 +0200350 static_executable: true,
351
dimitryb8b3a762018-09-25 12:31:11 +0200352 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
353 // looking up symbols in the linker by mistake.
354 prefix_symbols: "__dl_",
355
356 sanitize: {
357 hwaddress: false,
358 },
dimitryb8b3a762018-09-25 12:31:11 +0200359
Colin Cross97f0aef2016-07-14 16:05:46 -0700360 static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -0700361 "liblinker_main",
Ryan Prichard80e40f02019-10-31 19:54:46 -0700362 "liblinker_malloc",
363
364 "libc++_static",
Colin Cross97f0aef2016-07-14 16:05:46 -0700365 "libc_nomalloc",
Ryan Prichard249757b2019-11-01 17:18:28 -0700366 "libc_dynamic_dispatch",
Dimitry Ivanov451909d2017-01-26 16:52:59 -0800367 "libm",
Ryan Prichardcdf71752020-12-16 03:37:22 -0800368 "libunwind",
Colin Cross97f0aef2016-07-14 16:05:46 -0700369 ],
Colin Cross97f0aef2016-07-14 16:05:46 -0700370
Ryan Prichardd9a41152019-10-14 16:58:53 -0700371 // Ensure that if the linker needs __gnu_Unwind_Find_exidx, then the linker will have a
372 // definition of the symbol. The linker links against libgcc.a, whose arm32 unwinder has a weak
373 // reference to __gnu_Unwind_Find_exidx, which isn't sufficient to pull in the strong definition
374 // of __gnu_Unwind_Find_exidx from libc. An unresolved weak reference would create a
375 // non-relative dynamic relocation in the linker binary, which complicates linker startup.
376 //
377 // This line should be unnecessary because the linker's dependency on libunwind_llvm.a should
378 // override libgcc.a, but this line provides a simpler guarantee. It can be removed once the
379 // linker stops linking against libgcc.a's arm32 unwinder.
380 whole_static_libs: ["libc_unwind_static"],
381
Ryan Prichard80e40f02019-10-31 19:54:46 -0700382 system_shared_libs: [],
383
384 // Opt out of native_coverage when opting out of system_shared_libs
385 native_coverage: false,
386}
387
388// ========================================================
389// linker[_asan][64] binary
390// ========================================================
391
392cc_binary {
Colin Cross97f0aef2016-07-14 16:05:46 -0700393 name: "linker",
Ryan Prichard80e40f02019-10-31 19:54:46 -0700394 defaults: [
395 "linker_bin_template",
396 "linux_bionic_supported",
397 "linker_version_script_overlay",
398 ],
399
Victor Khimenkod15229d2020-05-14 22:14:45 +0200400 srcs: [
401 "linker_translate_path.cpp",
402 ],
403
Colin Cross10fffb42016-12-08 09:57:35 -0800404 symlinks: ["linker_asan"],
Florian Mayerc10d0642023-03-22 16:12:49 -0700405 arch: {
406 arm64: {
407 symlinks: ["linker_hwasan"],
408 },
409 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700410 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700411 lib64: {
412 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800413 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700414 },
Pirama Arumuga Nainarfcd35382019-02-14 13:48:01 -0800415
Ryan Prichard80e40f02019-10-31 19:54:46 -0700416 compile_multilib: "both",
Ryan Prichard80e40f02019-10-31 19:54:46 -0700417
418 recovery_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -0700419 vendor_ramdisk_available: true,
Ryan Prichard80e40f02019-10-31 19:54:46 -0700420 apex_available: [
421 "//apex_available:platform",
422 "com.android.runtime",
423 ],
Pirama Arumuga Nainarfcd35382019-02-14 13:48:01 -0800424
Colin Cross97f0aef2016-07-14 16:05:46 -0700425 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800426 android: {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700427 srcs: [
428 "linker_debuggerd_android.cpp",
429 ],
Dan Albert4ea19212019-07-23 13:31:14 -0700430 static_libs: [
431 "libc++demangle",
432 "libdebuggerd_handler_fallback",
433 ],
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800434 },
Ryan Prichard80e40f02019-10-31 19:54:46 -0700435 linux_bionic: {
436 static_libs: [
437 "liblinker_debuggerd_stub",
438 ],
Yi Kong6f6daaa2020-12-10 01:27:44 +0800439 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700440 },
Yi Konga7e363f2020-10-01 04:10:01 +0800441
Yi Konge20a1d92022-01-25 03:19:58 +0800442 afdo: true,
Colin Cross97f0aef2016-07-14 16:05:46 -0700443}
dimitry11da1dc2018-01-05 13:35:43 +0100444
Ryan Prichard80e40f02019-10-31 19:54:46 -0700445// ========================================================
446// assorted modules
447// ========================================================
448
Elliott Hughes90f96b92019-05-09 15:56:39 -0700449sh_binary {
450 name: "ldd",
Rupert Shuttlewortha7e29a82021-02-18 13:35:22 +0000451 src: "ldd.sh",
Elliott Hughes90f96b92019-05-09 15:56:39 -0700452}
453
Collin Fijalkovichc9521e02021-04-29 11:31:50 -0700454// Used to generate binaries that can be backed by transparent hugepages.
455cc_defaults {
456 name: "linker_hugepage_aligned",
457 arch: {
458 arm64: {
459 ldflags: ["-z max-page-size=0x200000"],
460 },
461 x86_64: {
462 ldflags: ["-z max-page-size=0x200000"],
463 },
464 },
465}
466
dimitry11da1dc2018-01-05 13:35:43 +0100467cc_library {
468 // NOTE: --exclude-libs=libgcc.a makes sure that any symbols ld-android.so pulls from
469 // libgcc.a are made static to ld-android.so. This in turn ensures that libraries that
470 // a) pull symbols from libgcc.a and b) depend on ld-android.so will not rely on ld-android.so
471 // to provide those symbols, but will instead pull them from libgcc.a. Specifically,
472 // we use this property to make sure libc.so has its own copy of the code from
473 // libgcc.a it uses.
474 //
475 // DO NOT REMOVE --exclude-libs!
476
Yi Kong7786a342018-08-31 19:01:56 -0700477 ldflags: [
478 "-Wl,--exclude-libs=libgcc.a",
Yi Kong7ac2afb2019-05-06 16:23:10 -0700479 "-Wl,--exclude-libs=libgcc_stripped.a",
Yi Kong7786a342018-08-31 19:01:56 -0700480 "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
481 "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
Elliott Hughes3e4f6032022-10-22 03:54:59 +0000482 "-Wl,--exclude-libs=libclang_rt.builtins-riscv64-android.a",
Ryan Prichardef147872021-01-28 14:06:52 -0800483 "-Wl,--exclude-libs=libclang_rt.builtins-i686-android.a",
Yi Kong7786a342018-08-31 19:01:56 -0700484 "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
485 ],
dimitry11da1dc2018-01-05 13:35:43 +0100486
487 // for x86, exclude libgcc_eh.a for the same reasons as above
488 arch: {
489 x86: {
490 ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
491 },
492 x86_64: {
493 ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
494 },
495 },
dimitry581723e2018-01-05 14:31:44 +0100496
497 srcs: ["ld_android.cpp"],
dimitry11da1dc2018-01-05 13:35:43 +0100498 cflags: [
499 "-Wall",
500 "-Wextra",
501 "-Wunused",
502 "-Werror",
503 ],
504 stl: "none",
505
506 name: "ld-android",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000507 defaults: [
508 "linux_bionic_supported",
509 "linker_version_script_overlay",
510 ],
Yifan Hong5a39cee2020-01-21 16:43:56 -0800511 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -0700512 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +0900513 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +0200514 native_bridge_supported: true,
dimitry11da1dc2018-01-05 13:35:43 +0100515
Ryan Prichard470b6662018-03-27 22:10:55 -0700516 nocrt: true,
dimitry11da1dc2018-01-05 13:35:43 +0100517 system_shared_libs: [],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +0100518 header_libs: ["libc_headers"],
dimitry11da1dc2018-01-05 13:35:43 +0100519
Pirama Arumuga Nainarfcd35382019-02-14 13:48:01 -0800520 // Opt out of native_coverage when opting out of system_shared_libs
521 native_coverage: false,
522
dimitry11da1dc2018-01-05 13:35:43 +0100523 sanitize: {
524 never: true,
525 },
Jiyong Parke87e0dc2019-10-02 17:09:33 +0900526
527 apex_available: [
528 "//apex_available:platform",
529 "com.android.runtime",
530 ],
dimitry11da1dc2018-01-05 13:35:43 +0100531}
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800532
533cc_test {
534 name: "linker-unit-tests",
Colin Cross0cc60af2021-09-30 14:04:39 -0700535 test_suites: ["device-tests"],
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800536
537 cflags: [
538 "-g",
539 "-Wall",
540 "-Wextra",
541 "-Wunused",
542 "-Werror",
543 ],
544
545 // We need to access Bionic private headers in the linker.
546 include_dirs: ["bionic/libc"],
547
548 srcs: [
549 // Tests.
550 "linker_block_allocator_test.cpp",
551 "linker_config_test.cpp",
552 "linked_list_test.cpp",
Tamas Petz8d55d182020-02-24 14:15:25 +0100553 "linker_note_gnu_property_test.cpp",
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800554 "linker_sleb128_test.cpp",
555 "linker_utils_test.cpp",
Ryan Prichard129f7a12019-12-23 16:45:47 -0800556 "linker_gnu_hash_test.cpp",
Kalesh Singh0396f872024-02-02 22:11:08 -0800557 "linker_crt_pad_segment_test.cpp",
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800558
559 // Parts of the linker that we're testing.
Kalesh Singh0396f872024-02-02 22:11:08 -0800560 ":elf_note_sources",
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800561 "linker_block_allocator.cpp",
562 "linker_config.cpp",
Ryan Prichard551565e2019-12-23 16:03:14 -0800563 "linker_debug.cpp",
Tamas Petz8d55d182020-02-24 14:15:25 +0100564 "linker_note_gnu_property.cpp",
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800565 "linker_test_globals.cpp",
566 "linker_utils.cpp",
Kalesh Singh0396f872024-02-02 22:11:08 -0800567 "linker_phdr.cpp",
568 "linker_mapped_file_fragment.cpp",
569 "linker_sdk_versions.cpp",
570 "linker_dlwarning.cpp",
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800571 ],
572
573 static_libs: [
574 "libasync_safe",
575 "libbase",
Jiyong Park7157dfb2022-08-19 13:09:18 +0900576 "liblog_for_runtime_apex",
Kalesh Singh4084b552024-03-13 13:35:49 -0700577 "libprocinfo", // For procinfo::MappedFileSize()
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800578 ],
Ryan Prichard129f7a12019-12-23 16:45:47 -0800579
Kalesh Singh0396f872024-02-02 22:11:08 -0800580 data_libs: [
581 "crt_pad_segment_disabled",
582 "crt_pad_segment_enabled",
583 "no_crt_pad_segment",
584 ],
585
Ryan Prichard129f7a12019-12-23 16:45:47 -0800586 arch: {
587 arm: {
588 srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
589 },
590 arm64: {
591 srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
592 },
593 },
594}
595
596cc_benchmark {
597 name: "linker-benchmarks",
598
599 srcs: [
600 "linker_gnu_hash_benchmark.cpp",
601 ],
602
603 arch: {
604 arm: {
605 srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
606 },
607 arm64: {
608 srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
609 },
610 },
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800611}