Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 1 | // ======================================================== |
| 2 | // linker_wrapper - Linux Bionic (on the host) |
| 3 | // ======================================================== |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 4 | |
Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 5 | // 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 Badour | aa7d835 | 2021-02-19 13:06:22 -0800 | [diff] [blame] | 12 | package { |
| 13 | default_applicable_licenses: ["bionic_linker_license"], |
| 14 | } |
| 15 | |
| 16 | license { |
| 17 | name: "bionic_linker_license", |
| 18 | visibility: [":__subpackages__"], |
| 19 | license_kinds: [ |
| 20 | "SPDX-license-identifier-BSD", |
| 21 | ], |
| 22 | license_text: [ |
| 23 | "NOTICE", |
| 24 | ], |
| 25 | } |
| 26 | |
Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 27 | cc_object { |
| 28 | name: "linker_wrapper", |
| 29 | host_supported: true, |
| 30 | device_supported: false, |
Colin Cross | da446cc | 2022-03-08 15:07:57 -0800 | [diff] [blame] | 31 | enabled: false, |
Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 32 | target: { |
Elliott Hughes | d50a1de | 2018-02-05 17:30:57 -0800 | [diff] [blame] | 33 | linux_bionic: { |
| 34 | enabled: true, |
| 35 | }, |
Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 36 | }, |
| 37 | |
| 38 | cflags: [ |
| 39 | "-fno-stack-protector", |
| 40 | "-Wstrict-overflow=5", |
| 41 | "-fvisibility=hidden", |
| 42 | "-Wall", |
| 43 | "-Wextra", |
| 44 | "-Wno-unused", |
| 45 | "-Werror", |
| 46 | ], |
| 47 | |
| 48 | srcs: [ |
| 49 | "linker_wrapper.cpp", |
| 50 | ], |
| 51 | arch: { |
Jiyong Park | 3b47d60 | 2020-09-18 16:15:53 +0900 | [diff] [blame] | 52 | arm64: { |
Colin Cross | a0a591a | 2021-06-11 12:46:45 -0700 | [diff] [blame] | 53 | srcs: ["arch/arm64/linker_wrapper_begin.S"], |
Jiyong Park | 3b47d60 | 2020-09-18 16:15:53 +0900 | [diff] [blame] | 54 | }, |
Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 55 | riscv64: { |
| 56 | srcs: ["arch/riscv64/linker_wrapper_begin.S"], |
| 57 | }, |
Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 58 | x86_64: { |
Colin Cross | a0a591a | 2021-06-11 12:46:45 -0700 | [diff] [blame] | 59 | srcs: ["arch/x86_64/linker_wrapper_begin.S"], |
Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 60 | }, |
| 61 | }, |
| 62 | |
Martin Stjernholm | 82d84bc | 2020-04-06 20:32:09 +0100 | [diff] [blame] | 63 | header_libs: ["libc_headers"], |
| 64 | |
Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 65 | // We need to access Bionic private headers in the linker. |
| 66 | include_dirs: ["bionic/libc"], |
| 67 | } |
| 68 | |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 69 | // ======================================================== |
| 70 | // linker default configuration |
| 71 | // ======================================================== |
| 72 | |
| 73 | // Configuration for the linker binary and any of its static libraries. |
| 74 | cc_defaults { |
| 75 | name: "linker_defaults", |
| 76 | arch: { |
| 77 | arm: { |
| 78 | cflags: ["-D__work_around_b_24465209__"], |
| 79 | }, |
| 80 | x86: { |
| 81 | cflags: ["-D__work_around_b_24465209__"], |
| 82 | }, |
| 83 | }, |
| 84 | |
| 85 | cflags: [ |
| 86 | "-fno-stack-protector", |
| 87 | "-Wstrict-overflow=5", |
| 88 | "-fvisibility=hidden", |
| 89 | "-Wall", |
| 90 | "-Wextra", |
| 91 | "-Wunused", |
| 92 | "-Werror", |
| 93 | ], |
| 94 | |
| 95 | // TODO: split out the asflags. |
| 96 | asflags: [ |
| 97 | "-fno-stack-protector", |
| 98 | "-Wstrict-overflow=5", |
| 99 | "-fvisibility=hidden", |
| 100 | "-Wall", |
| 101 | "-Wextra", |
| 102 | "-Wunused", |
| 103 | "-Werror", |
| 104 | ], |
| 105 | |
| 106 | product_variables: { |
| 107 | debuggable: { |
| 108 | cppflags: ["-DUSE_LD_CONFIG_FILE"], |
| 109 | }, |
| 110 | }, |
| 111 | |
| 112 | cppflags: ["-Wold-style-cast"], |
| 113 | |
| 114 | static_libs: [ |
| 115 | "libziparchive", |
| 116 | "libbase", |
| 117 | "libz", |
| 118 | |
| 119 | "libasync_safe", |
| 120 | |
Jiyong Park | 7157dfb | 2022-08-19 13:09:18 +0900 | [diff] [blame] | 121 | "liblog_for_runtime_apex", |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 122 | ], |
| 123 | |
| 124 | // We need to access Bionic private headers in the linker. |
| 125 | include_dirs: ["bionic/libc"], |
| 126 | } |
| 127 | |
| 128 | // ======================================================== |
| 129 | // linker components |
| 130 | // ======================================================== |
| 131 | |
| 132 | // Enable a module on all targets the linker runs on (ordinary Android targets, Linux Bionic, and |
| 133 | // native bridge implementations). |
| 134 | cc_defaults { |
| 135 | name: "linker_all_targets", |
| 136 | defaults: ["linux_bionic_supported"], |
| 137 | recovery_available: true, |
Yifan Hong | b04490d | 2020-10-21 18:36:36 -0700 | [diff] [blame] | 138 | vendor_ramdisk_available: true, |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 139 | native_bridge_supported: true, |
| 140 | } |
| 141 | |
| 142 | cc_library_static { |
Ryan Prichard | 249757b | 2019-11-01 17:18:28 -0700 | [diff] [blame] | 143 | name: "liblinker_main", |
| 144 | defaults: ["linker_defaults", "linker_all_targets"], |
| 145 | srcs: ["linker_main.cpp"], |
| 146 | |
| 147 | // Ensure that the compiler won't insert string function calls before ifuncs are resolved. |
| 148 | cflags: ["-ffreestanding"], |
| 149 | } |
| 150 | |
| 151 | cc_library_static { |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 152 | name: "liblinker_malloc", |
| 153 | defaults: ["linker_defaults", "linker_all_targets"], |
| 154 | srcs: ["linker_memory.cpp"], |
| 155 | } |
| 156 | |
| 157 | cc_library_static { |
| 158 | name: "liblinker_debuggerd_stub", |
| 159 | defaults: ["linker_defaults", "linker_all_targets"], |
| 160 | srcs: ["linker_debuggerd_stub.cpp"], |
| 161 | } |
| 162 | |
| 163 | // ======================================================== |
| 164 | // template for the linker binary |
| 165 | // ======================================================== |
| 166 | |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 167 | filegroup { |
| 168 | name: "linker_sources", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 169 | srcs: [ |
| 170 | "dlfcn.cpp", |
| 171 | "linker.cpp", |
Elliott Hughes | 838dbac | 2023-08-22 14:07:48 -0700 | [diff] [blame] | 172 | "linker_auxv.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 173 | "linker_block_allocator.cpp", |
Dimitry Ivanov | 769b33f | 2016-07-21 11:33:40 -0700 | [diff] [blame] | 174 | "linker_dlwarning.cpp", |
Evgenii Stepanov | 0a3637d | 2016-07-06 13:20:59 -0700 | [diff] [blame] | 175 | "linker_cfi.cpp", |
Dimitry Ivanov | 4cabfaa | 2017-03-07 11:19:05 -0800 | [diff] [blame] | 176 | "linker_config.cpp", |
Ryan Prichard | 551565e | 2019-12-23 16:03:14 -0800 | [diff] [blame] | 177 | "linker_debug.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 178 | "linker_gdb_support.cpp", |
Dimitry Ivanov | 48ec288 | 2016-08-04 11:50:36 -0700 | [diff] [blame] | 179 | "linker_globals.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 180 | "linker_libc_support.c", |
Dimitry Ivanov | 451909d | 2017-01-26 16:52:59 -0800 | [diff] [blame] | 181 | "linker_libcxx_support.cpp", |
Dimitry Ivanov | b943f30 | 2016-08-03 16:00:10 -0700 | [diff] [blame] | 182 | "linker_namespaces.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 183 | "linker_logger.cpp", |
| 184 | "linker_mapped_file_fragment.cpp", |
Tamas Petz | 8d55d18 | 2020-02-24 14:15:25 +0100 | [diff] [blame] | 185 | "linker_note_gnu_property.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 186 | "linker_phdr.cpp", |
Ryan Prichard | 339ecef | 2020-01-02 16:36:06 -0800 | [diff] [blame] | 187 | "linker_relocate.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 188 | "linker_sdk_versions.cpp", |
Dimitry Ivanov | 48ec288 | 2016-08-04 11:50:36 -0700 | [diff] [blame] | 189 | "linker_soinfo.cpp", |
Collin Fijalkovich | 47d27aa | 2021-03-24 10:17:39 -0700 | [diff] [blame] | 190 | "linker_transparent_hugepage_support.cpp", |
Ryan Prichard | 45d1349 | 2019-01-03 02:51:30 -0800 | [diff] [blame] | 191 | "linker_tls.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 192 | "linker_utils.cpp", |
| 193 | "rt.cpp", |
| 194 | ], |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 195 | } |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 196 | |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 197 | filegroup { |
| 198 | name: "linker_sources_arm", |
| 199 | srcs: [ |
| 200 | "arch/arm/begin.S", |
Ryan Prichard | 129f7a1 | 2019-12-23 16:45:47 -0800 | [diff] [blame] | 201 | "arch/arm_neon/linker_gnu_hash_neon.cpp", |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 202 | ], |
| 203 | } |
| 204 | |
| 205 | filegroup { |
| 206 | name: "linker_sources_arm64", |
| 207 | srcs: [ |
| 208 | "arch/arm64/begin.S", |
Ryan Prichard | ffaae70 | 2019-01-23 17:47:10 -0800 | [diff] [blame] | 209 | "arch/arm64/tlsdesc_resolver.S", |
Ryan Prichard | 129f7a1 | 2019-12-23 16:45:47 -0800 | [diff] [blame] | 210 | "arch/arm_neon/linker_gnu_hash_neon.cpp", |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 211 | ], |
| 212 | } |
| 213 | |
| 214 | filegroup { |
Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 215 | name: "linker_sources_riscv64", |
| 216 | srcs: [ |
| 217 | "arch/riscv64/begin.S", |
| 218 | ], |
| 219 | } |
| 220 | |
| 221 | filegroup { |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 222 | name: "linker_sources_x86", |
| 223 | srcs: [ |
| 224 | "arch/x86/begin.S", |
| 225 | ], |
| 226 | } |
| 227 | |
| 228 | filegroup { |
| 229 | name: "linker_sources_x86_64", |
| 230 | srcs: [ |
| 231 | "arch/x86_64/begin.S", |
| 232 | ], |
| 233 | } |
| 234 | |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 235 | cc_defaults { |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 236 | name: "linker_version_script_overlay", |
| 237 | arch: { |
Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 238 | arm: { version_script: "linker.arm.map" }, |
| 239 | arm64: { version_script: "linker.generic.map" }, |
| 240 | riscv64: { version_script: "linker.generic.map" }, |
| 241 | x86: { version_script: "linker.generic.map" }, |
| 242 | x86_64: { version_script: "linker.generic.map" }, |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 243 | }, |
| 244 | } |
| 245 | |
| 246 | // A template for the linker binary. May be inherited by native bridge implementations. |
| 247 | cc_defaults { |
| 248 | name: "linker_bin_template", |
| 249 | defaults: ["linker_defaults"], |
| 250 | |
| 251 | srcs: [":linker_sources"], |
| 252 | |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 253 | arch: { |
| 254 | arm: { |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 255 | srcs: [":linker_sources_arm"], |
Christopher Ferris | d37df2b | 2022-08-11 17:27:50 -0700 | [diff] [blame] | 256 | |
| 257 | // Arm 32 bit does not produce complete exidx unwind information |
| 258 | // so keep the .debug_frame which is relatively small and does |
| 259 | // include needed unwind information. |
| 260 | // See b/242162222 for details. |
| 261 | strip: { |
| 262 | keep_symbols_and_debug_frame: true, |
| 263 | }, |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 264 | }, |
| 265 | arm64: { |
| 266 | srcs: [":linker_sources_arm64"], |
Christopher Ferris | d37df2b | 2022-08-11 17:27:50 -0700 | [diff] [blame] | 267 | |
| 268 | // Leave the symbols in the shared library so that stack unwinders can produce |
| 269 | // meaningful name resolution. |
| 270 | strip: { |
| 271 | keep_symbols: true, |
| 272 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 273 | }, |
Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 274 | riscv64: { |
| 275 | srcs: [":linker_sources_riscv64"], |
| 276 | |
| 277 | // Leave the symbols in the shared library so that stack unwinders can produce |
| 278 | // meaningful name resolution. |
| 279 | strip: { |
| 280 | keep_symbols: true, |
| 281 | }, |
| 282 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 283 | x86: { |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 284 | srcs: [":linker_sources_x86"], |
Christopher Ferris | d37df2b | 2022-08-11 17:27:50 -0700 | [diff] [blame] | 285 | |
| 286 | // Leave the symbols in the shared library so that stack unwinders can produce |
| 287 | // meaningful name resolution. |
| 288 | strip: { |
| 289 | keep_symbols: true, |
| 290 | }, |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 291 | }, |
| 292 | x86_64: { |
| 293 | srcs: [":linker_sources_x86_64"], |
Christopher Ferris | d37df2b | 2022-08-11 17:27:50 -0700 | [diff] [blame] | 294 | |
| 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 | }, |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 300 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 301 | }, |
| 302 | |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 303 | // -shared is used to overwrite the -Bstatic and -static flags triggered by enabling |
| 304 | // static_executable. This dynamic linker is actually a shared object linked with static |
| 305 | // libraries. |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 306 | ldflags: [ |
| 307 | "-shared", |
| 308 | "-Wl,-Bsymbolic", |
| 309 | "-Wl,--exclude-libs,ALL", |
dimitry | 8e8c2c0 | 2018-01-04 12:08:32 +0100 | [diff] [blame] | 310 | "-Wl,-soname,ld-android.so", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 311 | ], |
| 312 | |
Dimitry Ivanov | fc0d480 | 2016-12-06 11:10:09 -0800 | [diff] [blame] | 313 | // we are going to link libc++_static manually because |
| 314 | // when stl is not set to "none" build system adds libdl |
| 315 | // to the list of static libraries which needs to be |
| 316 | // avoided in the case of building loader. |
| 317 | stl: "none", |
| 318 | |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 319 | // we don't want crtbegin.o (because we have begin.o), so unset it |
| 320 | // just for this module |
| 321 | nocrt: true, |
| 322 | |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 323 | static_executable: true, |
| 324 | |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 325 | // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb |
| 326 | // looking up symbols in the linker by mistake. |
| 327 | prefix_symbols: "__dl_", |
| 328 | |
| 329 | sanitize: { |
| 330 | hwaddress: false, |
| 331 | }, |
dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 332 | |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 333 | static_libs: [ |
Ryan Prichard | 249757b | 2019-11-01 17:18:28 -0700 | [diff] [blame] | 334 | "liblinker_main", |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 335 | "liblinker_malloc", |
| 336 | |
| 337 | "libc++_static", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 338 | "libc_nomalloc", |
Ryan Prichard | 249757b | 2019-11-01 17:18:28 -0700 | [diff] [blame] | 339 | "libc_dynamic_dispatch", |
Dimitry Ivanov | 451909d | 2017-01-26 16:52:59 -0800 | [diff] [blame] | 340 | "libm", |
Ryan Prichard | cdf7175 | 2020-12-16 03:37:22 -0800 | [diff] [blame] | 341 | "libunwind", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 342 | ], |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 343 | |
Ryan Prichard | d9a4115 | 2019-10-14 16:58:53 -0700 | [diff] [blame] | 344 | // Ensure that if the linker needs __gnu_Unwind_Find_exidx, then the linker will have a |
| 345 | // definition of the symbol. The linker links against libgcc.a, whose arm32 unwinder has a weak |
| 346 | // reference to __gnu_Unwind_Find_exidx, which isn't sufficient to pull in the strong definition |
| 347 | // of __gnu_Unwind_Find_exidx from libc. An unresolved weak reference would create a |
| 348 | // non-relative dynamic relocation in the linker binary, which complicates linker startup. |
| 349 | // |
| 350 | // This line should be unnecessary because the linker's dependency on libunwind_llvm.a should |
| 351 | // override libgcc.a, but this line provides a simpler guarantee. It can be removed once the |
| 352 | // linker stops linking against libgcc.a's arm32 unwinder. |
| 353 | whole_static_libs: ["libc_unwind_static"], |
| 354 | |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 355 | system_shared_libs: [], |
| 356 | |
| 357 | // Opt out of native_coverage when opting out of system_shared_libs |
| 358 | native_coverage: false, |
| 359 | } |
| 360 | |
| 361 | // ======================================================== |
| 362 | // linker[_asan][64] binary |
| 363 | // ======================================================== |
| 364 | |
| 365 | cc_binary { |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 366 | name: "linker", |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 367 | defaults: [ |
| 368 | "linker_bin_template", |
| 369 | "linux_bionic_supported", |
| 370 | "linker_version_script_overlay", |
| 371 | ], |
| 372 | |
Victor Khimenko | d15229d | 2020-05-14 22:14:45 +0200 | [diff] [blame] | 373 | srcs: [ |
| 374 | "linker_translate_path.cpp", |
| 375 | ], |
| 376 | |
Colin Cross | 10fffb4 | 2016-12-08 09:57:35 -0800 | [diff] [blame] | 377 | symlinks: ["linker_asan"], |
Florian Mayer | c10d064 | 2023-03-22 16:12:49 -0700 | [diff] [blame] | 378 | arch: { |
| 379 | arm64: { |
| 380 | symlinks: ["linker_hwasan"], |
| 381 | }, |
| 382 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 383 | multilib: { |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 384 | lib64: { |
| 385 | suffix: "64", |
Colin Cross | 10fffb4 | 2016-12-08 09:57:35 -0800 | [diff] [blame] | 386 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 387 | }, |
Pirama Arumuga Nainar | fcd3538 | 2019-02-14 13:48:01 -0800 | [diff] [blame] | 388 | |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 389 | compile_multilib: "both", |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 390 | |
| 391 | recovery_available: true, |
Yifan Hong | b04490d | 2020-10-21 18:36:36 -0700 | [diff] [blame] | 392 | vendor_ramdisk_available: true, |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 393 | apex_available: [ |
| 394 | "//apex_available:platform", |
| 395 | "com.android.runtime", |
| 396 | ], |
Pirama Arumuga Nainar | fcd3538 | 2019-02-14 13:48:01 -0800 | [diff] [blame] | 397 | |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 398 | target: { |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 399 | android: { |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 400 | srcs: [ |
| 401 | "linker_debuggerd_android.cpp", |
| 402 | ], |
Dan Albert | 4ea1921 | 2019-07-23 13:31:14 -0700 | [diff] [blame] | 403 | static_libs: [ |
| 404 | "libc++demangle", |
| 405 | "libdebuggerd_handler_fallback", |
| 406 | ], |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 407 | }, |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 408 | linux_bionic: { |
| 409 | static_libs: [ |
| 410 | "liblinker_debuggerd_stub", |
| 411 | ], |
Yi Kong | 6f6daaa | 2020-12-10 01:27:44 +0800 | [diff] [blame] | 412 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 413 | }, |
Yi Kong | a7e363f | 2020-10-01 04:10:01 +0800 | [diff] [blame] | 414 | |
Yi Kong | e20a1d9 | 2022-01-25 03:19:58 +0800 | [diff] [blame] | 415 | afdo: true, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 416 | } |
dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 417 | |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 418 | // ======================================================== |
| 419 | // assorted modules |
| 420 | // ======================================================== |
| 421 | |
Elliott Hughes | 90f96b9 | 2019-05-09 15:56:39 -0700 | [diff] [blame] | 422 | sh_binary { |
| 423 | name: "ldd", |
Rupert Shuttleworth | a7e29a8 | 2021-02-18 13:35:22 +0000 | [diff] [blame] | 424 | src: "ldd.sh", |
Elliott Hughes | 90f96b9 | 2019-05-09 15:56:39 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Collin Fijalkovich | c9521e0 | 2021-04-29 11:31:50 -0700 | [diff] [blame] | 427 | // Used to generate binaries that can be backed by transparent hugepages. |
| 428 | cc_defaults { |
| 429 | name: "linker_hugepage_aligned", |
| 430 | arch: { |
| 431 | arm64: { |
| 432 | ldflags: ["-z max-page-size=0x200000"], |
| 433 | }, |
| 434 | x86_64: { |
| 435 | ldflags: ["-z max-page-size=0x200000"], |
| 436 | }, |
| 437 | }, |
| 438 | } |
| 439 | |
dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 440 | cc_library { |
| 441 | // NOTE: --exclude-libs=libgcc.a makes sure that any symbols ld-android.so pulls from |
| 442 | // libgcc.a are made static to ld-android.so. This in turn ensures that libraries that |
| 443 | // a) pull symbols from libgcc.a and b) depend on ld-android.so will not rely on ld-android.so |
| 444 | // to provide those symbols, but will instead pull them from libgcc.a. Specifically, |
| 445 | // we use this property to make sure libc.so has its own copy of the code from |
| 446 | // libgcc.a it uses. |
| 447 | // |
| 448 | // DO NOT REMOVE --exclude-libs! |
| 449 | |
Yi Kong | 7786a34 | 2018-08-31 19:01:56 -0700 | [diff] [blame] | 450 | ldflags: [ |
| 451 | "-Wl,--exclude-libs=libgcc.a", |
Yi Kong | 7ac2afb | 2019-05-06 16:23:10 -0700 | [diff] [blame] | 452 | "-Wl,--exclude-libs=libgcc_stripped.a", |
Yi Kong | 7786a34 | 2018-08-31 19:01:56 -0700 | [diff] [blame] | 453 | "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a", |
| 454 | "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a", |
Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 455 | "-Wl,--exclude-libs=libclang_rt.builtins-riscv64-android.a", |
Ryan Prichard | ef14787 | 2021-01-28 14:06:52 -0800 | [diff] [blame] | 456 | "-Wl,--exclude-libs=libclang_rt.builtins-i686-android.a", |
Yi Kong | 7786a34 | 2018-08-31 19:01:56 -0700 | [diff] [blame] | 457 | "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a", |
| 458 | ], |
dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 459 | |
| 460 | // for x86, exclude libgcc_eh.a for the same reasons as above |
| 461 | arch: { |
| 462 | x86: { |
| 463 | ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"], |
| 464 | }, |
| 465 | x86_64: { |
| 466 | ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"], |
| 467 | }, |
| 468 | }, |
dimitry | 581723e | 2018-01-05 14:31:44 +0100 | [diff] [blame] | 469 | |
| 470 | srcs: ["ld_android.cpp"], |
dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 471 | cflags: [ |
| 472 | "-Wall", |
| 473 | "-Wextra", |
| 474 | "-Wunused", |
| 475 | "-Werror", |
| 476 | ], |
| 477 | stl: "none", |
| 478 | |
| 479 | name: "ld-android", |
Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 480 | defaults: ["linux_bionic_supported", "linker_version_script_overlay"], |
Yifan Hong | 5a39cee | 2020-01-21 16:43:56 -0800 | [diff] [blame] | 481 | ramdisk_available: true, |
Yifan Hong | b04490d | 2020-10-21 18:36:36 -0700 | [diff] [blame] | 482 | vendor_ramdisk_available: true, |
Jiyong Park | 5603c6e | 2018-04-27 21:53:11 +0900 | [diff] [blame] | 483 | recovery_available: true, |
dimitry | 7f04880 | 2019-05-03 15:57:34 +0200 | [diff] [blame] | 484 | native_bridge_supported: true, |
dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 485 | |
Ryan Prichard | 470b666 | 2018-03-27 22:10:55 -0700 | [diff] [blame] | 486 | nocrt: true, |
dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 487 | system_shared_libs: [], |
Martin Stjernholm | 82d84bc | 2020-04-06 20:32:09 +0100 | [diff] [blame] | 488 | header_libs: ["libc_headers"], |
dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 489 | |
Pirama Arumuga Nainar | fcd3538 | 2019-02-14 13:48:01 -0800 | [diff] [blame] | 490 | // Opt out of native_coverage when opting out of system_shared_libs |
| 491 | native_coverage: false, |
| 492 | |
dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 493 | sanitize: { |
| 494 | never: true, |
| 495 | }, |
Jiyong Park | e87e0dc | 2019-10-02 17:09:33 +0900 | [diff] [blame] | 496 | |
| 497 | apex_available: [ |
| 498 | "//apex_available:platform", |
| 499 | "com.android.runtime", |
| 500 | ], |
dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 501 | } |
Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 502 | |
| 503 | cc_test { |
| 504 | name: "linker-unit-tests", |
Colin Cross | 0cc60af | 2021-09-30 14:04:39 -0700 | [diff] [blame] | 505 | test_suites: ["device-tests"], |
Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 506 | |
| 507 | cflags: [ |
| 508 | "-g", |
| 509 | "-Wall", |
| 510 | "-Wextra", |
| 511 | "-Wunused", |
| 512 | "-Werror", |
| 513 | ], |
| 514 | |
| 515 | // We need to access Bionic private headers in the linker. |
| 516 | include_dirs: ["bionic/libc"], |
| 517 | |
| 518 | srcs: [ |
| 519 | // Tests. |
| 520 | "linker_block_allocator_test.cpp", |
| 521 | "linker_config_test.cpp", |
| 522 | "linked_list_test.cpp", |
Tamas Petz | 8d55d18 | 2020-02-24 14:15:25 +0100 | [diff] [blame] | 523 | "linker_note_gnu_property_test.cpp", |
Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 524 | "linker_sleb128_test.cpp", |
| 525 | "linker_utils_test.cpp", |
Ryan Prichard | 129f7a1 | 2019-12-23 16:45:47 -0800 | [diff] [blame] | 526 | "linker_gnu_hash_test.cpp", |
Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 527 | |
| 528 | // Parts of the linker that we're testing. |
| 529 | "linker_block_allocator.cpp", |
| 530 | "linker_config.cpp", |
Ryan Prichard | 551565e | 2019-12-23 16:03:14 -0800 | [diff] [blame] | 531 | "linker_debug.cpp", |
Tamas Petz | 8d55d18 | 2020-02-24 14:15:25 +0100 | [diff] [blame] | 532 | "linker_note_gnu_property.cpp", |
Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 533 | "linker_test_globals.cpp", |
| 534 | "linker_utils.cpp", |
| 535 | ], |
| 536 | |
| 537 | static_libs: [ |
| 538 | "libasync_safe", |
| 539 | "libbase", |
Jiyong Park | 7157dfb | 2022-08-19 13:09:18 +0900 | [diff] [blame] | 540 | "liblog_for_runtime_apex", |
Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 541 | ], |
Ryan Prichard | 129f7a1 | 2019-12-23 16:45:47 -0800 | [diff] [blame] | 542 | |
| 543 | arch: { |
| 544 | arm: { |
| 545 | srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"], |
| 546 | }, |
| 547 | arm64: { |
| 548 | srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"], |
| 549 | }, |
| 550 | }, |
| 551 | } |
| 552 | |
| 553 | cc_benchmark { |
| 554 | name: "linker-benchmarks", |
| 555 | |
| 556 | srcs: [ |
| 557 | "linker_gnu_hash_benchmark.cpp", |
| 558 | ], |
| 559 | |
| 560 | arch: { |
| 561 | arm: { |
| 562 | srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"], |
| 563 | }, |
| 564 | arm64: { |
| 565 | srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"], |
| 566 | }, |
| 567 | }, |
Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 568 | } |