blob: ea4e6996596f7ac6c293343cfb4f9b94e98d1cf2 [file] [log] [blame]
Bob Badouraa7d8352021-02-19 13:06:22 -08001package {
Aditya Choudharyd9d37c02024-02-02 13:57:12 +00002 default_team: "trendy_team_native_tools_libraries",
Bob Badouraa7d8352021-02-19 13:06:22 -08003 default_applicable_licenses: ["bionic_linker_license"],
4}
5
6license {
7 name: "bionic_linker_license",
8 visibility: [":__subpackages__"],
9 license_kinds: [
10 "SPDX-license-identifier-BSD",
11 ],
12 license_text: [
13 "NOTICE",
14 ],
15}
16
Elliott Hughesb1b2e372024-07-08 14:27:46 +000017linker_common_flags = [
18 "-fno-stack-protector",
19 "-Wstrict-overflow=5",
20 "-fvisibility=hidden",
21 "-Wall",
22 "-Wextra",
23 "-Wunused",
24 "-Werror",
25]
26
Elliott Hughes4b5d62e2024-06-20 16:21:08 +000027// ========================================================
28// linker_wrapper - Linux Bionic (on the host)
29// ========================================================
30
31// This is used for bionic on (host) Linux to bootstrap our linker embedded into
32// a binary.
33//
34// Host bionic binaries do not have a PT_INTERP section, instead this gets
35// embedded as the entry point, and the linker is embedded as ELF sections in
36// each binary. There's a linker script that sets all of that up (generated by
37// extract_linker), and defines the extern symbols used in this file.
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070038cc_object {
39 name: "linker_wrapper",
40 host_supported: true,
41 device_supported: false,
Colin Crossda446cc2022-03-08 15:07:57 -080042 enabled: false,
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070043 target: {
Elliott Hughesd50a1de2018-02-05 17:30:57 -080044 linux_bionic: {
45 enabled: true,
46 },
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070047 },
48
Elliott Hughesb1b2e372024-07-08 14:27:46 +000049 cflags: linker_common_flags,
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070050
51 srcs: [
52 "linker_wrapper.cpp",
53 ],
54 arch: {
Jiyong Park3b47d602020-09-18 16:15:53 +090055 arm64: {
Colin Crossa0a591a2021-06-11 12:46:45 -070056 srcs: ["arch/arm64/linker_wrapper_begin.S"],
Jiyong Park3b47d602020-09-18 16:15:53 +090057 },
Elliott Hughes3e4f6032022-10-22 03:54:59 +000058 riscv64: {
59 srcs: ["arch/riscv64/linker_wrapper_begin.S"],
60 },
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070061 x86_64: {
Colin Crossa0a591a2021-06-11 12:46:45 -070062 srcs: ["arch/x86_64/linker_wrapper_begin.S"],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070063 },
64 },
65
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010066 header_libs: ["libc_headers"],
67
Dan Willemsen7ccc50d2017-09-18 21:28:14 -070068 // We need to access Bionic private headers in the linker.
69 include_dirs: ["bionic/libc"],
70}
71
Ryan Prichard80e40f02019-10-31 19:54:46 -070072// ========================================================
73// linker default configuration
74// ========================================================
75
76// Configuration for the linker binary and any of its static libraries.
77cc_defaults {
78 name: "linker_defaults",
Ryan Prichard80e40f02019-10-31 19:54:46 -070079
Elliott Hughesb1b2e372024-07-08 14:27:46 +000080 cflags: linker_common_flags,
81 asflags: linker_common_flags,
Ryan Prichard80e40f02019-10-31 19:54:46 -070082
83 product_variables: {
84 debuggable: {
85 cppflags: ["-DUSE_LD_CONFIG_FILE"],
86 },
87 },
88
89 cppflags: ["-Wold-style-cast"],
90
91 static_libs: [
92 "libziparchive",
93 "libbase",
94 "libz",
95
96 "libasync_safe",
97
Jiyong Park7157dfb2022-08-19 13:09:18 +090098 "liblog_for_runtime_apex",
Ryan Prichard80e40f02019-10-31 19:54:46 -070099 ],
100
101 // We need to access Bionic private headers in the linker.
102 include_dirs: ["bionic/libc"],
Florian Mayer4edc20d2024-10-30 14:24:26 -0700103
104 sanitize: {
105 // Supporting memtag_globals in the linker would be tricky,
106 // because it relocates itself very early.
107 memtag_globals: false,
108 },
Ryan Prichard80e40f02019-10-31 19:54:46 -0700109}
110
111// ========================================================
112// linker components
113// ========================================================
114
115// Enable a module on all targets the linker runs on (ordinary Android targets, Linux Bionic, and
116// native bridge implementations).
117cc_defaults {
118 name: "linker_all_targets",
119 defaults: ["linux_bionic_supported"],
120 recovery_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -0700121 vendor_ramdisk_available: true,
Ryan Prichard80e40f02019-10-31 19:54:46 -0700122 native_bridge_supported: true,
123}
124
125cc_library_static {
Ryan Prichard249757b2019-11-01 17:18:28 -0700126 name: "liblinker_main",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000127 defaults: [
128 "linker_defaults",
129 "linker_all_targets",
130 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700131 srcs: ["linker_main.cpp"],
132
133 // Ensure that the compiler won't insert string function calls before ifuncs are resolved.
134 cflags: ["-ffreestanding"],
Spandan Das0a6cfe92024-01-04 18:06:50 +0000135 apex_available: [
136 "com.android.runtime",
137 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700138}
139
140cc_library_static {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700141 name: "liblinker_malloc",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000142 defaults: [
143 "linker_defaults",
144 "linker_all_targets",
145 ],
Ryan Prichard80e40f02019-10-31 19:54:46 -0700146 srcs: ["linker_memory.cpp"],
Spandan Das0a6cfe92024-01-04 18:06:50 +0000147 apex_available: [
148 "com.android.runtime",
149 ],
Ryan Prichard80e40f02019-10-31 19:54:46 -0700150}
151
152cc_library_static {
153 name: "liblinker_debuggerd_stub",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000154 defaults: [
155 "linker_defaults",
156 "linker_all_targets",
157 ],
Ryan Prichard80e40f02019-10-31 19:54:46 -0700158 srcs: ["linker_debuggerd_stub.cpp"],
159}
160
161// ========================================================
162// template for the linker binary
163// ========================================================
164
dimitryb8b3a762018-09-25 12:31:11 +0200165filegroup {
166 name: "linker_sources",
Colin Cross97f0aef2016-07-14 16:05:46 -0700167 srcs: [
168 "dlfcn.cpp",
169 "linker.cpp",
Elliott Hughes838dbac2023-08-22 14:07:48 -0700170 "linker_auxv.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700171 "linker_block_allocator.cpp",
Dimitry Ivanov769b33f2016-07-21 11:33:40 -0700172 "linker_dlwarning.cpp",
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700173 "linker_cfi.cpp",
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -0800174 "linker_config.cpp",
Ryan Prichard551565e2019-12-23 16:03:14 -0800175 "linker_debug.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700176 "linker_gdb_support.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -0700177 "linker_globals.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700178 "linker_libc_support.c",
Dimitry Ivanov451909d2017-01-26 16:52:59 -0800179 "linker_libcxx_support.cpp",
Dimitry Ivanovb943f302016-08-03 16:00:10 -0700180 "linker_namespaces.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700181 "linker_logger.cpp",
182 "linker_mapped_file_fragment.cpp",
Tamas Petz8d55d182020-02-24 14:15:25 +0100183 "linker_note_gnu_property.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700184 "linker_phdr.cpp",
Kalesh Singhce1c3cf2024-09-30 13:26:23 -0700185 "linker_phdr_16kib_compat.cpp",
Ryan Prichard339ecef2020-01-02 16:36:06 -0800186 "linker_relocate.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700187 "linker_sdk_versions.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -0700188 "linker_soinfo.cpp",
Collin Fijalkovich47d27aa2021-03-24 10:17:39 -0700189 "linker_transparent_hugepage_support.cpp",
Ryan Prichard45d13492019-01-03 02:51:30 -0800190 "linker_tls.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -0700191 "linker_utils.cpp",
192 "rt.cpp",
193 ],
dimitryb8b3a762018-09-25 12:31:11 +0200194}
Colin Cross97f0aef2016-07-14 16:05:46 -0700195
dimitryb8b3a762018-09-25 12:31:11 +0200196filegroup {
197 name: "linker_sources_arm",
198 srcs: [
199 "arch/arm/begin.S",
Ryan Prichard129f7a12019-12-23 16:45:47 -0800200 "arch/arm_neon/linker_gnu_hash_neon.cpp",
dimitryb8b3a762018-09-25 12:31:11 +0200201 ],
202}
203
204filegroup {
205 name: "linker_sources_arm64",
206 srcs: [
207 "arch/arm64/begin.S",
Ryan Prichardffaae702019-01-23 17:47:10 -0800208 "arch/arm64/tlsdesc_resolver.S",
Ryan Prichard129f7a12019-12-23 16:45:47 -0800209 "arch/arm_neon/linker_gnu_hash_neon.cpp",
dimitryb8b3a762018-09-25 12:31:11 +0200210 ],
211}
212
213filegroup {
Elliott Hughes3e4f6032022-10-22 03:54:59 +0000214 name: "linker_sources_riscv64",
215 srcs: [
216 "arch/riscv64/begin.S",
Paul Kirth4d437782024-01-30 23:03:14 +0000217 "arch/riscv64/tlsdesc_resolver.S",
Elliott Hughes3e4f6032022-10-22 03:54:59 +0000218 ],
219}
220
221filegroup {
dimitryb8b3a762018-09-25 12:31:11 +0200222 name: "linker_sources_x86",
223 srcs: [
224 "arch/x86/begin.S",
225 ],
226}
227
228filegroup {
229 name: "linker_sources_x86_64",
230 srcs: [
231 "arch/x86_64/begin.S",
232 ],
233}
234
dimitryb8b3a762018-09-25 12:31:11 +0200235cc_defaults {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700236 name: "linker_version_script_overlay",
237 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000238 arm: {
239 version_script: "linker.arm.map",
240 },
241 arm64: {
242 version_script: "linker.generic.map",
243 },
244 riscv64: {
245 version_script: "linker.generic.map",
246 },
247 x86: {
248 version_script: "linker.generic.map",
249 },
250 x86_64: {
251 version_script: "linker.generic.map",
252 },
Ryan Prichard80e40f02019-10-31 19:54:46 -0700253 },
254}
255
256// A template for the linker binary. May be inherited by native bridge implementations.
257cc_defaults {
258 name: "linker_bin_template",
Elliott Hughes89aada12024-07-01 21:59:04 +0000259 defaults: [
260 "linker_defaults",
261 "keep_symbols",
262 ],
Ryan Prichard80e40f02019-10-31 19:54:46 -0700263
264 srcs: [":linker_sources"],
265
Colin Cross97f0aef2016-07-14 16:05:46 -0700266 arch: {
267 arm: {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700268 srcs: [":linker_sources_arm"],
Ryan Prichard80e40f02019-10-31 19:54:46 -0700269 },
270 arm64: {
271 srcs: [":linker_sources_arm64"],
Colin Cross97f0aef2016-07-14 16:05:46 -0700272 },
Elliott Hughes3e4f6032022-10-22 03:54:59 +0000273 riscv64: {
274 srcs: [":linker_sources_riscv64"],
Elliott Hughes3e4f6032022-10-22 03:54:59 +0000275 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700276 x86: {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700277 srcs: [":linker_sources_x86"],
278 },
279 x86_64: {
280 srcs: [":linker_sources_x86_64"],
281 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700282 },
283
Elliott Hughes4b5d62e2024-06-20 16:21:08 +0000284 static_executable: true,
285
Ryan Prichard80e40f02019-10-31 19:54:46 -0700286 // -shared is used to overwrite the -Bstatic and -static flags triggered by enabling
Elliott Hughes4b5d62e2024-06-20 16:21:08 +0000287 // static_executable. The dynamic linker is actually a shared object linked with static
Ryan Prichard80e40f02019-10-31 19:54:46 -0700288 // libraries.
Colin Cross97f0aef2016-07-14 16:05:46 -0700289 ldflags: [
290 "-shared",
291 "-Wl,-Bsymbolic",
292 "-Wl,--exclude-libs,ALL",
dimitry8e8c2c02018-01-04 12:08:32 +0100293 "-Wl,-soname,ld-android.so",
Peter Collingbournec630da52024-03-26 13:24:06 -0700294 // When the linker applies its own IRELATIVE relocations, it will only read DT_REL[A] and
295 // DT_JMPREL, not DT_ANDROID_REL[A], which can also theoretically contain IRELATIVE
296 // relocations. lld has been taught to not store them there as a bug workaround (see
297 // https://llvm.org/pr86751) but the workaround could be removed at some point in the
298 // future. So we explicitly prevent it from doing so by disabling DT_ANDROID_REL[A] when
299 // linking the linker (DT_RELR cannot encode IRELATIVE relocations).
300 "-Wl,--pack-dyn-relocs=relr",
Colin Cross97f0aef2016-07-14 16:05:46 -0700301 ],
302
Elliott Hughes4b5d62e2024-06-20 16:21:08 +0000303 // We link libc++_static manually because otherwise the build system will
304 // automatically add libdl to the list of static libraries.
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800305 stl: "none",
306
Elliott Hughes4b5d62e2024-06-20 16:21:08 +0000307 // We don't want crtbegin.o (because we have our own arch/*/begin.o),
308 // so unset it just for this module.
Colin Cross97f0aef2016-07-14 16:05:46 -0700309 nocrt: true,
310
dimitryb8b3a762018-09-25 12:31:11 +0200311 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
312 // looking up symbols in the linker by mistake.
313 prefix_symbols: "__dl_",
314
315 sanitize: {
316 hwaddress: false,
Florian Mayerc0aa70a2024-06-24 15:49:20 -0700317 memtag_stack: false,
dimitryb8b3a762018-09-25 12:31:11 +0200318 },
dimitryb8b3a762018-09-25 12:31:11 +0200319
Colin Cross97f0aef2016-07-14 16:05:46 -0700320 static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -0700321 "liblinker_main",
Ryan Prichard80e40f02019-10-31 19:54:46 -0700322 "liblinker_malloc",
323
Elliott Hughes4b5d62e2024-06-20 16:21:08 +0000324 // We use a version of libc++ built without exceptions,
325 // because accessing EH globals uses ELF TLS,
326 // which is not supported in the loader.
Ryan Prichard0bac1cb2024-05-03 01:15:00 +0000327 "libc++_static_noexcept",
Elliott Hughes4b5d62e2024-06-20 16:21:08 +0000328
Colin Cross97f0aef2016-07-14 16:05:46 -0700329 "libc_nomalloc",
Ryan Prichard249757b2019-11-01 17:18:28 -0700330 "libc_dynamic_dispatch",
Dimitry Ivanov451909d2017-01-26 16:52:59 -0800331 "libm",
Ryan Prichardcdf71752020-12-16 03:37:22 -0800332 "libunwind",
Colin Cross97f0aef2016-07-14 16:05:46 -0700333 ],
Colin Cross97f0aef2016-07-14 16:05:46 -0700334
Ryan Prichard80e40f02019-10-31 19:54:46 -0700335 system_shared_libs: [],
336
337 // Opt out of native_coverage when opting out of system_shared_libs
338 native_coverage: false,
339}
340
341// ========================================================
342// linker[_asan][64] binary
343// ========================================================
344
Jihoon Kang1359d2f2024-12-06 23:11:14 +0000345cc_defaults {
346 name: "linker_binary_defaults",
Ryan Prichard80e40f02019-10-31 19:54:46 -0700347 defaults: [
348 "linker_bin_template",
Ryan Prichard80e40f02019-10-31 19:54:46 -0700349 "linker_version_script_overlay",
350 ],
351
Victor Khimenkod15229d2020-05-14 22:14:45 +0200352 srcs: [
353 "linker_translate_path.cpp",
354 ],
355
Colin Cross10fffb42016-12-08 09:57:35 -0800356 symlinks: ["linker_asan"],
Florian Mayerc10d0642023-03-22 16:12:49 -0700357 arch: {
358 arm64: {
359 symlinks: ["linker_hwasan"],
360 },
361 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700362 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700363 lib64: {
364 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800365 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700366 },
Pirama Arumuga Nainarfcd35382019-02-14 13:48:01 -0800367
Ryan Prichard80e40f02019-10-31 19:54:46 -0700368 compile_multilib: "both",
Ryan Prichard80e40f02019-10-31 19:54:46 -0700369
Ryan Prichard80e40f02019-10-31 19:54:46 -0700370 apex_available: [
371 "//apex_available:platform",
372 "com.android.runtime",
373 ],
Pirama Arumuga Nainarfcd35382019-02-14 13:48:01 -0800374
Colin Cross97f0aef2016-07-14 16:05:46 -0700375 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800376 android: {
Ryan Prichard80e40f02019-10-31 19:54:46 -0700377 srcs: [
378 "linker_debuggerd_android.cpp",
379 ],
Dan Albert4ea19212019-07-23 13:31:14 -0700380 static_libs: [
Ryan Prichard0bac1cb2024-05-03 01:15:00 +0000381 "libc++demangle_noexcept",
Dan Albert4ea19212019-07-23 13:31:14 -0700382 "libdebuggerd_handler_fallback",
383 ],
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800384 },
Ryan Prichard80e40f02019-10-31 19:54:46 -0700385 linux_bionic: {
386 static_libs: [
387 "liblinker_debuggerd_stub",
388 ],
Yi Kong6f6daaa2020-12-10 01:27:44 +0800389 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700390 },
Yi Konga7e363f2020-10-01 04:10:01 +0800391
Yi Konge20a1d92022-01-25 03:19:58 +0800392 afdo: true,
Colin Cross97f0aef2016-07-14 16:05:46 -0700393}
dimitry11da1dc2018-01-05 13:35:43 +0100394
Jihoon Kang1359d2f2024-12-06 23:11:14 +0000395cc_binary {
396 name: "linker",
397 defaults: [
398 "linux_bionic_supported",
399 "linker_binary_defaults",
400 ],
401
402 vendor_ramdisk_available: true,
403}
404
405cc_binary {
406 name: "linker.recovery",
407 defaults: [
408 "linker_binary_defaults",
409 ],
410
411 recovery: true,
412 stem: "linker",
413}
414
Ryan Prichard80e40f02019-10-31 19:54:46 -0700415// ========================================================
416// assorted modules
417// ========================================================
418
Elliott Hughes90f96b92019-05-09 15:56:39 -0700419sh_binary {
420 name: "ldd",
Rupert Shuttlewortha7e29a82021-02-18 13:35:22 +0000421 src: "ldd.sh",
Elliott Hughes90f96b92019-05-09 15:56:39 -0700422}
423
Collin Fijalkovichc9521e02021-04-29 11:31:50 -0700424// Used to generate binaries that can be backed by transparent hugepages.
425cc_defaults {
426 name: "linker_hugepage_aligned",
427 arch: {
428 arm64: {
429 ldflags: ["-z max-page-size=0x200000"],
430 },
431 x86_64: {
432 ldflags: ["-z max-page-size=0x200000"],
433 },
434 },
435}
436
dimitry11da1dc2018-01-05 13:35:43 +0100437cc_library {
dimitry581723e2018-01-05 14:31:44 +0100438 srcs: ["ld_android.cpp"],
dimitry11da1dc2018-01-05 13:35:43 +0100439 cflags: [
440 "-Wall",
441 "-Wextra",
442 "-Wunused",
443 "-Werror",
444 ],
445 stl: "none",
446
447 name: "ld-android",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000448 defaults: [
449 "linux_bionic_supported",
450 "linker_version_script_overlay",
451 ],
Yifan Hong5a39cee2020-01-21 16:43:56 -0800452 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -0700453 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +0900454 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +0200455 native_bridge_supported: true,
dimitry11da1dc2018-01-05 13:35:43 +0100456
Ryan Prichard470b6662018-03-27 22:10:55 -0700457 nocrt: true,
dimitry11da1dc2018-01-05 13:35:43 +0100458 system_shared_libs: [],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +0100459 header_libs: ["libc_headers"],
dimitry11da1dc2018-01-05 13:35:43 +0100460
Pirama Arumuga Nainarfcd35382019-02-14 13:48:01 -0800461 // Opt out of native_coverage when opting out of system_shared_libs
462 native_coverage: false,
463
dimitry11da1dc2018-01-05 13:35:43 +0100464 sanitize: {
465 never: true,
466 },
Jiyong Parke87e0dc2019-10-02 17:09:33 +0900467
468 apex_available: [
469 "//apex_available:platform",
470 "com.android.runtime",
471 ],
dimitry11da1dc2018-01-05 13:35:43 +0100472}
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800473
474cc_test {
475 name: "linker-unit-tests",
Colin Cross0cc60af2021-09-30 14:04:39 -0700476 test_suites: ["device-tests"],
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800477
478 cflags: [
479 "-g",
480 "-Wall",
481 "-Wextra",
482 "-Wunused",
483 "-Werror",
484 ],
485
486 // We need to access Bionic private headers in the linker.
487 include_dirs: ["bionic/libc"],
488
489 srcs: [
490 // Tests.
491 "linker_block_allocator_test.cpp",
492 "linker_config_test.cpp",
493 "linked_list_test.cpp",
Tamas Petz8d55d182020-02-24 14:15:25 +0100494 "linker_note_gnu_property_test.cpp",
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800495 "linker_sleb128_test.cpp",
496 "linker_utils_test.cpp",
Ryan Prichard129f7a12019-12-23 16:45:47 -0800497 "linker_gnu_hash_test.cpp",
Kalesh Singh0396f872024-02-02 22:11:08 -0800498 "linker_crt_pad_segment_test.cpp",
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800499
500 // Parts of the linker that we're testing.
Kalesh Singh0396f872024-02-02 22:11:08 -0800501 ":elf_note_sources",
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800502 "linker_block_allocator.cpp",
503 "linker_config.cpp",
Ryan Prichard551565e2019-12-23 16:03:14 -0800504 "linker_debug.cpp",
Tamas Petz8d55d182020-02-24 14:15:25 +0100505 "linker_note_gnu_property.cpp",
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800506 "linker_test_globals.cpp",
507 "linker_utils.cpp",
Kalesh Singh0396f872024-02-02 22:11:08 -0800508 "linker_phdr.cpp",
509 "linker_mapped_file_fragment.cpp",
510 "linker_sdk_versions.cpp",
511 "linker_dlwarning.cpp",
Pawan Wagh8e5de062024-10-17 18:05:19 +0000512 "linker_phdr_16kib_compat.cpp"
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800513 ],
514
515 static_libs: [
516 "libasync_safe",
517 "libbase",
Jiyong Park7157dfb2022-08-19 13:09:18 +0900518 "liblog_for_runtime_apex",
Kalesh Singh4084b552024-03-13 13:35:49 -0700519 "libprocinfo", // For procinfo::MappedFileSize()
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800520 ],
Ryan Prichard129f7a12019-12-23 16:45:47 -0800521
Kalesh Singh0396f872024-02-02 22:11:08 -0800522 data_libs: [
523 "crt_pad_segment_disabled",
524 "crt_pad_segment_enabled",
525 "no_crt_pad_segment",
526 ],
527
Ryan Prichard129f7a12019-12-23 16:45:47 -0800528 arch: {
529 arm: {
530 srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
531 },
532 arm64: {
533 srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
534 },
535 },
536}
537
538cc_benchmark {
539 name: "linker-benchmarks",
540
541 srcs: [
542 "linker_gnu_hash_benchmark.cpp",
543 ],
544
545 arch: {
546 arm: {
547 srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
548 },
549 arm64: {
550 srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"],
551 },
552 },
Elliott Hughes15a2b7b2019-02-15 13:48:38 -0800553}
Elliott Hughes07445132024-12-06 17:17:24 -0500554
555cc_fuzz {
556 name: "ElfReader_fuzzer",
557 srcs: [
558 "ElfReader_fuzzer.cpp",
559 "linker.cpp",
560 "linker_block_allocator.cpp",
561 "linker_debug.cpp",
562 "linker_dlwarning.cpp",
563 "linker_globals.cpp",
564 "linker_mapped_file_fragment.cpp",
565 "linker_phdr.cpp",
Elliott Hughes00d1bd62024-12-12 07:54:04 -0800566 "linker_phdr_16kib_compat.cpp",
Elliott Hughes07445132024-12-06 17:17:24 -0500567 "linker_sdk_versions.cpp",
568 "linker_utils.cpp",
569 ":elf_note_sources",
570 ],
571 static_libs: [
572 "libasync_safe",
573 "libbase",
574 "libziparchive",
575 ],
576 include_dirs: ["bionic/libc"],
577 // TODO: use all the architectures' files.
578 // We'll either need to give them unique names across architectures,
579 // or change soong to preserve subdirectories in `corpus:`,
580 // and maybe also the [deprecated] LLVM fuzzer infrastructure?
581 corpus: [":bionic_prebuilt_test_elf_files_arm64"],
582}