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