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