| Bob Badour | aa7d835 | 2021-02-19 13:06:22 -0800 | [diff] [blame] | 1 | package { | 
| Aditya Choudhary | d9d37c0 | 2024-02-02 13:57:12 +0000 | [diff] [blame] | 2 |     default_team: "trendy_team_native_tools_libraries", | 
| Bob Badour | aa7d835 | 2021-02-19 13:06:22 -0800 | [diff] [blame] | 3 |     default_applicable_licenses: ["bionic_linker_license"], | 
 | 4 | } | 
 | 5 |  | 
 | 6 | license { | 
 | 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 Hughes | b1b2e37 | 2024-07-08 14:27:46 +0000 | [diff] [blame] | 17 | linker_common_flags = [ | 
 | 18 |     "-fno-stack-protector", | 
 | 19 |     "-Wstrict-overflow=5", | 
 | 20 |     "-fvisibility=hidden", | 
 | 21 |     "-Wall", | 
 | 22 |     "-Wextra", | 
 | 23 |     "-Wunused", | 
 | 24 |     "-Werror", | 
 | 25 | ] | 
 | 26 |  | 
| Elliott Hughes | 4b5d62e | 2024-06-20 16:21:08 +0000 | [diff] [blame] | 27 | // ======================================================== | 
 | 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 Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 38 | cc_object { | 
 | 39 |     name: "linker_wrapper", | 
 | 40 |     host_supported: true, | 
 | 41 |     device_supported: false, | 
| Colin Cross | da446cc | 2022-03-08 15:07:57 -0800 | [diff] [blame] | 42 |     enabled: false, | 
| Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 43 |     target: { | 
| Elliott Hughes | d50a1de | 2018-02-05 17:30:57 -0800 | [diff] [blame] | 44 |         linux_bionic: { | 
 | 45 |             enabled: true, | 
 | 46 |         }, | 
| Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 47 |     }, | 
 | 48 |  | 
| Elliott Hughes | b1b2e37 | 2024-07-08 14:27:46 +0000 | [diff] [blame] | 49 |     cflags: linker_common_flags, | 
| Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 50 |  | 
 | 51 |     srcs: [ | 
 | 52 |         "linker_wrapper.cpp", | 
 | 53 |     ], | 
 | 54 |     arch: { | 
| Jiyong Park | 3b47d60 | 2020-09-18 16:15:53 +0900 | [diff] [blame] | 55 |         arm64: { | 
| Colin Cross | a0a591a | 2021-06-11 12:46:45 -0700 | [diff] [blame] | 56 |             srcs: ["arch/arm64/linker_wrapper_begin.S"], | 
| Jiyong Park | 3b47d60 | 2020-09-18 16:15:53 +0900 | [diff] [blame] | 57 |         }, | 
| Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 58 |         riscv64: { | 
 | 59 |             srcs: ["arch/riscv64/linker_wrapper_begin.S"], | 
 | 60 |         }, | 
| Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 61 |         x86_64: { | 
| Colin Cross | a0a591a | 2021-06-11 12:46:45 -0700 | [diff] [blame] | 62 |             srcs: ["arch/x86_64/linker_wrapper_begin.S"], | 
| Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 63 |         }, | 
 | 64 |     }, | 
 | 65 |  | 
| Martin Stjernholm | 82d84bc | 2020-04-06 20:32:09 +0100 | [diff] [blame] | 66 |     header_libs: ["libc_headers"], | 
 | 67 |  | 
| Dan Willemsen | 7ccc50d | 2017-09-18 21:28:14 -0700 | [diff] [blame] | 68 |     // We need to access Bionic private headers in the linker. | 
 | 69 |     include_dirs: ["bionic/libc"], | 
 | 70 | } | 
 | 71 |  | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 72 | // ======================================================== | 
 | 73 | // linker default configuration | 
 | 74 | // ======================================================== | 
 | 75 |  | 
 | 76 | // Configuration for the linker binary and any of its static libraries. | 
 | 77 | cc_defaults { | 
 | 78 |     name: "linker_defaults", | 
 | 79 |     arch: { | 
 | 80 |         arm: { | 
 | 81 |             cflags: ["-D__work_around_b_24465209__"], | 
 | 82 |         }, | 
 | 83 |         x86: { | 
 | 84 |             cflags: ["-D__work_around_b_24465209__"], | 
 | 85 |         }, | 
 | 86 |     }, | 
 | 87 |  | 
| Elliott Hughes | b1b2e37 | 2024-07-08 14:27:46 +0000 | [diff] [blame] | 88 |     cflags: linker_common_flags, | 
 | 89 |     asflags: linker_common_flags, | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 90 |  | 
 | 91 |     product_variables: { | 
 | 92 |         debuggable: { | 
 | 93 |             cppflags: ["-DUSE_LD_CONFIG_FILE"], | 
 | 94 |         }, | 
 | 95 |     }, | 
 | 96 |  | 
 | 97 |     cppflags: ["-Wold-style-cast"], | 
 | 98 |  | 
 | 99 |     static_libs: [ | 
 | 100 |         "libziparchive", | 
 | 101 |         "libbase", | 
 | 102 |         "libz", | 
 | 103 |  | 
 | 104 |         "libasync_safe", | 
 | 105 |  | 
| Jiyong Park | 7157dfb | 2022-08-19 13:09:18 +0900 | [diff] [blame] | 106 |         "liblog_for_runtime_apex", | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 107 |     ], | 
 | 108 |  | 
 | 109 |     // We need to access Bionic private headers in the linker. | 
 | 110 |     include_dirs: ["bionic/libc"], | 
 | 111 | } | 
 | 112 |  | 
 | 113 | // ======================================================== | 
 | 114 | // linker components | 
 | 115 | // ======================================================== | 
 | 116 |  | 
 | 117 | // Enable a module on all targets the linker runs on (ordinary Android targets, Linux Bionic, and | 
 | 118 | // native bridge implementations). | 
 | 119 | cc_defaults { | 
 | 120 |     name: "linker_all_targets", | 
 | 121 |     defaults: ["linux_bionic_supported"], | 
 | 122 |     recovery_available: true, | 
| Yifan Hong | b04490d | 2020-10-21 18:36:36 -0700 | [diff] [blame] | 123 |     vendor_ramdisk_available: true, | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 124 |     native_bridge_supported: true, | 
 | 125 | } | 
 | 126 |  | 
 | 127 | cc_library_static { | 
| Ryan Prichard | 249757b | 2019-11-01 17:18:28 -0700 | [diff] [blame] | 128 |     name: "liblinker_main", | 
| Elliott Hughes | 1eacc0e | 2024-01-19 19:05:36 +0000 | [diff] [blame] | 129 |     defaults: [ | 
 | 130 |         "linker_defaults", | 
 | 131 |         "linker_all_targets", | 
 | 132 |     ], | 
| Ryan Prichard | 249757b | 2019-11-01 17:18:28 -0700 | [diff] [blame] | 133 |     srcs: ["linker_main.cpp"], | 
 | 134 |  | 
 | 135 |     // Ensure that the compiler won't insert string function calls before ifuncs are resolved. | 
 | 136 |     cflags: ["-ffreestanding"], | 
| Spandan Das | 0a6cfe9 | 2024-01-04 18:06:50 +0000 | [diff] [blame] | 137 |     apex_available: [ | 
 | 138 |         "com.android.runtime", | 
 | 139 |     ], | 
| Ryan Prichard | 249757b | 2019-11-01 17:18:28 -0700 | [diff] [blame] | 140 | } | 
 | 141 |  | 
 | 142 | cc_library_static { | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 143 |     name: "liblinker_malloc", | 
| Elliott Hughes | 1eacc0e | 2024-01-19 19:05:36 +0000 | [diff] [blame] | 144 |     defaults: [ | 
 | 145 |         "linker_defaults", | 
 | 146 |         "linker_all_targets", | 
 | 147 |     ], | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 148 |     srcs: ["linker_memory.cpp"], | 
| Spandan Das | 0a6cfe9 | 2024-01-04 18:06:50 +0000 | [diff] [blame] | 149 |     apex_available: [ | 
 | 150 |         "com.android.runtime", | 
 | 151 |     ], | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 152 | } | 
 | 153 |  | 
 | 154 | cc_library_static { | 
 | 155 |     name: "liblinker_debuggerd_stub", | 
| Elliott Hughes | 1eacc0e | 2024-01-19 19:05:36 +0000 | [diff] [blame] | 156 |     defaults: [ | 
 | 157 |         "linker_defaults", | 
 | 158 |         "linker_all_targets", | 
 | 159 |     ], | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 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", | 
| Kalesh Singh | ce1c3cf | 2024-09-30 13:26:23 -0700 | [diff] [blame] | 187 |         "linker_phdr_16kib_compat.cpp", | 
| Ryan Prichard | 339ecef | 2020-01-02 16:36:06 -0800 | [diff] [blame] | 188 |         "linker_relocate.cpp", | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 189 |         "linker_sdk_versions.cpp", | 
| Dimitry Ivanov | 48ec288 | 2016-08-04 11:50:36 -0700 | [diff] [blame] | 190 |         "linker_soinfo.cpp", | 
| Collin Fijalkovich | 47d27aa | 2021-03-24 10:17:39 -0700 | [diff] [blame] | 191 |         "linker_transparent_hugepage_support.cpp", | 
| Ryan Prichard | 45d1349 | 2019-01-03 02:51:30 -0800 | [diff] [blame] | 192 |         "linker_tls.cpp", | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 193 |         "linker_utils.cpp", | 
 | 194 |         "rt.cpp", | 
 | 195 |     ], | 
| dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 196 | } | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 197 |  | 
| dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 198 | filegroup { | 
 | 199 |     name: "linker_sources_arm", | 
 | 200 |     srcs: [ | 
 | 201 |         "arch/arm/begin.S", | 
| Ryan Prichard | 129f7a1 | 2019-12-23 16:45:47 -0800 | [diff] [blame] | 202 |         "arch/arm_neon/linker_gnu_hash_neon.cpp", | 
| dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 203 |     ], | 
 | 204 | } | 
 | 205 |  | 
 | 206 | filegroup { | 
 | 207 |     name: "linker_sources_arm64", | 
 | 208 |     srcs: [ | 
 | 209 |         "arch/arm64/begin.S", | 
| Ryan Prichard | ffaae70 | 2019-01-23 17:47:10 -0800 | [diff] [blame] | 210 |         "arch/arm64/tlsdesc_resolver.S", | 
| Ryan Prichard | 129f7a1 | 2019-12-23 16:45:47 -0800 | [diff] [blame] | 211 |         "arch/arm_neon/linker_gnu_hash_neon.cpp", | 
| dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 212 |     ], | 
 | 213 | } | 
 | 214 |  | 
 | 215 | filegroup { | 
| Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 216 |     name: "linker_sources_riscv64", | 
 | 217 |     srcs: [ | 
 | 218 |         "arch/riscv64/begin.S", | 
| Paul Kirth | 4d43778 | 2024-01-30 23:03:14 +0000 | [diff] [blame] | 219 |         "arch/riscv64/tlsdesc_resolver.S", | 
| Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 220 |     ], | 
 | 221 | } | 
 | 222 |  | 
 | 223 | filegroup { | 
| dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 224 |     name: "linker_sources_x86", | 
 | 225 |     srcs: [ | 
 | 226 |         "arch/x86/begin.S", | 
 | 227 |     ], | 
 | 228 | } | 
 | 229 |  | 
 | 230 | filegroup { | 
 | 231 |     name: "linker_sources_x86_64", | 
 | 232 |     srcs: [ | 
 | 233 |         "arch/x86_64/begin.S", | 
 | 234 |     ], | 
 | 235 | } | 
 | 236 |  | 
| dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 237 | cc_defaults { | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 238 |     name: "linker_version_script_overlay", | 
 | 239 |     arch: { | 
| Elliott Hughes | 1eacc0e | 2024-01-19 19:05:36 +0000 | [diff] [blame] | 240 |         arm: { | 
 | 241 |             version_script: "linker.arm.map", | 
 | 242 |         }, | 
 | 243 |         arm64: { | 
 | 244 |             version_script: "linker.generic.map", | 
 | 245 |         }, | 
 | 246 |         riscv64: { | 
 | 247 |             version_script: "linker.generic.map", | 
 | 248 |         }, | 
 | 249 |         x86: { | 
 | 250 |             version_script: "linker.generic.map", | 
 | 251 |         }, | 
 | 252 |         x86_64: { | 
 | 253 |             version_script: "linker.generic.map", | 
 | 254 |         }, | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 255 |     }, | 
 | 256 | } | 
 | 257 |  | 
 | 258 | // A template for the linker binary. May be inherited by native bridge implementations. | 
 | 259 | cc_defaults { | 
 | 260 |     name: "linker_bin_template", | 
| Elliott Hughes | 89aada1 | 2024-07-01 21:59:04 +0000 | [diff] [blame] | 261 |     defaults: [ | 
 | 262 |         "linker_defaults", | 
 | 263 |         "keep_symbols", | 
 | 264 |     ], | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 265 |  | 
 | 266 |     srcs: [":linker_sources"], | 
 | 267 |  | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 268 |     arch: { | 
 | 269 |         arm: { | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 270 |             srcs: [":linker_sources_arm"], | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 271 |         }, | 
 | 272 |         arm64: { | 
 | 273 |             srcs: [":linker_sources_arm64"], | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 274 |         }, | 
| Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 275 |         riscv64: { | 
 | 276 |             srcs: [":linker_sources_riscv64"], | 
| Elliott Hughes | 3e4f603 | 2022-10-22 03:54:59 +0000 | [diff] [blame] | 277 |         }, | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 278 |         x86: { | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 279 |             srcs: [":linker_sources_x86"], | 
 | 280 |         }, | 
 | 281 |         x86_64: { | 
 | 282 |             srcs: [":linker_sources_x86_64"], | 
 | 283 |         }, | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 284 |     }, | 
 | 285 |  | 
| Elliott Hughes | 4b5d62e | 2024-06-20 16:21:08 +0000 | [diff] [blame] | 286 |     static_executable: true, | 
 | 287 |  | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 288 |     // -shared is used to overwrite the -Bstatic and -static flags triggered by enabling | 
| Elliott Hughes | 4b5d62e | 2024-06-20 16:21:08 +0000 | [diff] [blame] | 289 |     // static_executable. The dynamic linker is actually a shared object linked with static | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 290 |     // libraries. | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 291 |     ldflags: [ | 
 | 292 |         "-shared", | 
 | 293 |         "-Wl,-Bsymbolic", | 
 | 294 |         "-Wl,--exclude-libs,ALL", | 
| dimitry | 8e8c2c0 | 2018-01-04 12:08:32 +0100 | [diff] [blame] | 295 |         "-Wl,-soname,ld-android.so", | 
| Peter Collingbourne | c630da5 | 2024-03-26 13:24:06 -0700 | [diff] [blame] | 296 |         // When the linker applies its own IRELATIVE relocations, it will only read DT_REL[A] and | 
 | 297 |         // DT_JMPREL, not DT_ANDROID_REL[A], which can also theoretically contain IRELATIVE | 
 | 298 |         // relocations. lld has been taught to not store them there as a bug workaround (see | 
 | 299 |         // https://llvm.org/pr86751) but the workaround could be removed at some point in the | 
 | 300 |         // future. So we explicitly prevent it from doing so by disabling DT_ANDROID_REL[A] when | 
 | 301 |         // linking the linker (DT_RELR cannot encode IRELATIVE relocations). | 
 | 302 |         "-Wl,--pack-dyn-relocs=relr", | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 303 |     ], | 
 | 304 |  | 
| Elliott Hughes | 4b5d62e | 2024-06-20 16:21:08 +0000 | [diff] [blame] | 305 |     // We link libc++_static manually because otherwise the build system will | 
 | 306 |     // automatically add libdl to the list of static libraries. | 
| Dimitry Ivanov | fc0d480 | 2016-12-06 11:10:09 -0800 | [diff] [blame] | 307 |     stl: "none", | 
 | 308 |  | 
| Elliott Hughes | 4b5d62e | 2024-06-20 16:21:08 +0000 | [diff] [blame] | 309 |     // We don't want crtbegin.o (because we have our own arch/*/begin.o), | 
 | 310 |     // so unset it just for this module. | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 311 |     nocrt: true, | 
 | 312 |  | 
| dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 313 |     // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb | 
 | 314 |     // looking up symbols in the linker by mistake. | 
 | 315 |     prefix_symbols: "__dl_", | 
 | 316 |  | 
 | 317 |     sanitize: { | 
 | 318 |         hwaddress: false, | 
| Florian Mayer | c0aa70a | 2024-06-24 15:49:20 -0700 | [diff] [blame] | 319 |         memtag_stack: false, | 
| dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 320 |     }, | 
| dimitry | b8b3a76 | 2018-09-25 12:31:11 +0200 | [diff] [blame] | 321 |  | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 322 |     static_libs: [ | 
| Ryan Prichard | 249757b | 2019-11-01 17:18:28 -0700 | [diff] [blame] | 323 |         "liblinker_main", | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 324 |         "liblinker_malloc", | 
 | 325 |  | 
| Elliott Hughes | 4b5d62e | 2024-06-20 16:21:08 +0000 | [diff] [blame] | 326 |         // We use a version of libc++ built without exceptions, | 
 | 327 |         // because accessing EH globals uses ELF TLS, | 
 | 328 |         // which is not supported in the loader. | 
| Ryan Prichard | 0bac1cb | 2024-05-03 01:15:00 +0000 | [diff] [blame] | 329 |         "libc++_static_noexcept", | 
| Elliott Hughes | 4b5d62e | 2024-06-20 16:21:08 +0000 | [diff] [blame] | 330 |  | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 331 |         "libc_nomalloc", | 
| Ryan Prichard | 249757b | 2019-11-01 17:18:28 -0700 | [diff] [blame] | 332 |         "libc_dynamic_dispatch", | 
| Dimitry Ivanov | 451909d | 2017-01-26 16:52:59 -0800 | [diff] [blame] | 333 |         "libm", | 
| Ryan Prichard | cdf7175 | 2020-12-16 03:37:22 -0800 | [diff] [blame] | 334 |         "libunwind", | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 335 |     ], | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 336 |  | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 337 |     system_shared_libs: [], | 
 | 338 |  | 
 | 339 |     // Opt out of native_coverage when opting out of system_shared_libs | 
 | 340 |     native_coverage: false, | 
 | 341 | } | 
 | 342 |  | 
 | 343 | // ======================================================== | 
 | 344 | // linker[_asan][64] binary | 
 | 345 | // ======================================================== | 
 | 346 |  | 
 | 347 | cc_binary { | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 348 |     name: "linker", | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 349 |     defaults: [ | 
 | 350 |         "linker_bin_template", | 
 | 351 |         "linux_bionic_supported", | 
 | 352 |         "linker_version_script_overlay", | 
 | 353 |     ], | 
 | 354 |  | 
| Victor Khimenko | d15229d | 2020-05-14 22:14:45 +0200 | [diff] [blame] | 355 |     srcs: [ | 
 | 356 |         "linker_translate_path.cpp", | 
 | 357 |     ], | 
 | 358 |  | 
| Colin Cross | 10fffb4 | 2016-12-08 09:57:35 -0800 | [diff] [blame] | 359 |     symlinks: ["linker_asan"], | 
| Florian Mayer | c10d064 | 2023-03-22 16:12:49 -0700 | [diff] [blame] | 360 |     arch: { | 
 | 361 |         arm64: { | 
 | 362 |             symlinks: ["linker_hwasan"], | 
 | 363 |         }, | 
 | 364 |     }, | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 365 |     multilib: { | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 366 |         lib64: { | 
 | 367 |             suffix: "64", | 
| Colin Cross | 10fffb4 | 2016-12-08 09:57:35 -0800 | [diff] [blame] | 368 |         }, | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 369 |     }, | 
| Pirama Arumuga Nainar | fcd3538 | 2019-02-14 13:48:01 -0800 | [diff] [blame] | 370 |  | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 371 |     compile_multilib: "both", | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 372 |  | 
 | 373 |     recovery_available: true, | 
| Yifan Hong | b04490d | 2020-10-21 18:36:36 -0700 | [diff] [blame] | 374 |     vendor_ramdisk_available: true, | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 375 |     apex_available: [ | 
 | 376 |         "//apex_available:platform", | 
 | 377 |         "com.android.runtime", | 
 | 378 |     ], | 
| Pirama Arumuga Nainar | fcd3538 | 2019-02-14 13:48:01 -0800 | [diff] [blame] | 379 |  | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 380 |     target: { | 
| Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 381 |         android: { | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 382 |             srcs: [ | 
 | 383 |                 "linker_debuggerd_android.cpp", | 
 | 384 |             ], | 
| Dan Albert | 4ea1921 | 2019-07-23 13:31:14 -0700 | [diff] [blame] | 385 |             static_libs: [ | 
| Ryan Prichard | 0bac1cb | 2024-05-03 01:15:00 +0000 | [diff] [blame] | 386 |                 "libc++demangle_noexcept", | 
| Dan Albert | 4ea1921 | 2019-07-23 13:31:14 -0700 | [diff] [blame] | 387 |                 "libdebuggerd_handler_fallback", | 
 | 388 |             ], | 
| Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 389 |         }, | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 390 |         linux_bionic: { | 
 | 391 |             static_libs: [ | 
 | 392 |                 "liblinker_debuggerd_stub", | 
 | 393 |             ], | 
| Yi Kong | 6f6daaa | 2020-12-10 01:27:44 +0800 | [diff] [blame] | 394 |         }, | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 395 |     }, | 
| Yi Kong | a7e363f | 2020-10-01 04:10:01 +0800 | [diff] [blame] | 396 |  | 
| Yi Kong | e20a1d9 | 2022-01-25 03:19:58 +0800 | [diff] [blame] | 397 |     afdo: true, | 
| Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 398 | } | 
| dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 399 |  | 
| Ryan Prichard | 80e40f0 | 2019-10-31 19:54:46 -0700 | [diff] [blame] | 400 | // ======================================================== | 
 | 401 | // assorted modules | 
 | 402 | // ======================================================== | 
 | 403 |  | 
| Elliott Hughes | 90f96b9 | 2019-05-09 15:56:39 -0700 | [diff] [blame] | 404 | sh_binary { | 
 | 405 |     name: "ldd", | 
| Rupert Shuttleworth | a7e29a8 | 2021-02-18 13:35:22 +0000 | [diff] [blame] | 406 |     src: "ldd.sh", | 
| Elliott Hughes | 90f96b9 | 2019-05-09 15:56:39 -0700 | [diff] [blame] | 407 | } | 
 | 408 |  | 
| Collin Fijalkovich | c9521e0 | 2021-04-29 11:31:50 -0700 | [diff] [blame] | 409 | // Used to generate binaries that can be backed by transparent hugepages. | 
 | 410 | cc_defaults { | 
 | 411 |     name: "linker_hugepage_aligned", | 
 | 412 |     arch: { | 
 | 413 |         arm64: { | 
 | 414 |             ldflags: ["-z max-page-size=0x200000"], | 
 | 415 |         }, | 
 | 416 |         x86_64: { | 
 | 417 |             ldflags: ["-z max-page-size=0x200000"], | 
 | 418 |         }, | 
 | 419 |     }, | 
 | 420 | } | 
 | 421 |  | 
| dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 422 | cc_library { | 
| dimitry | 581723e | 2018-01-05 14:31:44 +0100 | [diff] [blame] | 423 |     srcs: ["ld_android.cpp"], | 
| dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 424 |     cflags: [ | 
 | 425 |         "-Wall", | 
 | 426 |         "-Wextra", | 
 | 427 |         "-Wunused", | 
 | 428 |         "-Werror", | 
 | 429 |     ], | 
 | 430 |     stl: "none", | 
 | 431 |  | 
 | 432 |     name: "ld-android", | 
| Elliott Hughes | 1eacc0e | 2024-01-19 19:05:36 +0000 | [diff] [blame] | 433 |     defaults: [ | 
 | 434 |         "linux_bionic_supported", | 
 | 435 |         "linker_version_script_overlay", | 
 | 436 |     ], | 
| Yifan Hong | 5a39cee | 2020-01-21 16:43:56 -0800 | [diff] [blame] | 437 |     ramdisk_available: true, | 
| Yifan Hong | b04490d | 2020-10-21 18:36:36 -0700 | [diff] [blame] | 438 |     vendor_ramdisk_available: true, | 
| Jiyong Park | 5603c6e | 2018-04-27 21:53:11 +0900 | [diff] [blame] | 439 |     recovery_available: true, | 
| dimitry | 7f04880 | 2019-05-03 15:57:34 +0200 | [diff] [blame] | 440 |     native_bridge_supported: true, | 
| dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 441 |  | 
| Ryan Prichard | 470b666 | 2018-03-27 22:10:55 -0700 | [diff] [blame] | 442 |     nocrt: true, | 
| dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 443 |     system_shared_libs: [], | 
| Martin Stjernholm | 82d84bc | 2020-04-06 20:32:09 +0100 | [diff] [blame] | 444 |     header_libs: ["libc_headers"], | 
| dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 445 |  | 
| Pirama Arumuga Nainar | fcd3538 | 2019-02-14 13:48:01 -0800 | [diff] [blame] | 446 |     // Opt out of native_coverage when opting out of system_shared_libs | 
 | 447 |     native_coverage: false, | 
 | 448 |  | 
| dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 449 |     sanitize: { | 
 | 450 |         never: true, | 
 | 451 |     }, | 
| Jiyong Park | e87e0dc | 2019-10-02 17:09:33 +0900 | [diff] [blame] | 452 |  | 
 | 453 |     apex_available: [ | 
 | 454 |         "//apex_available:platform", | 
 | 455 |         "com.android.runtime", | 
 | 456 |     ], | 
| dimitry | 11da1dc | 2018-01-05 13:35:43 +0100 | [diff] [blame] | 457 | } | 
| Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 458 |  | 
 | 459 | cc_test { | 
 | 460 |     name: "linker-unit-tests", | 
| Colin Cross | 0cc60af | 2021-09-30 14:04:39 -0700 | [diff] [blame] | 461 |     test_suites: ["device-tests"], | 
| Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 462 |  | 
 | 463 |     cflags: [ | 
 | 464 |         "-g", | 
 | 465 |         "-Wall", | 
 | 466 |         "-Wextra", | 
 | 467 |         "-Wunused", | 
 | 468 |         "-Werror", | 
 | 469 |     ], | 
 | 470 |  | 
 | 471 |     // We need to access Bionic private headers in the linker. | 
 | 472 |     include_dirs: ["bionic/libc"], | 
 | 473 |  | 
 | 474 |     srcs: [ | 
 | 475 |         // Tests. | 
 | 476 |         "linker_block_allocator_test.cpp", | 
 | 477 |         "linker_config_test.cpp", | 
 | 478 |         "linked_list_test.cpp", | 
| Tamas Petz | 8d55d18 | 2020-02-24 14:15:25 +0100 | [diff] [blame] | 479 |         "linker_note_gnu_property_test.cpp", | 
| Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 480 |         "linker_sleb128_test.cpp", | 
 | 481 |         "linker_utils_test.cpp", | 
| Ryan Prichard | 129f7a1 | 2019-12-23 16:45:47 -0800 | [diff] [blame] | 482 |         "linker_gnu_hash_test.cpp", | 
| Kalesh Singh | 0396f87 | 2024-02-02 22:11:08 -0800 | [diff] [blame] | 483 |         "linker_crt_pad_segment_test.cpp", | 
| Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 484 |  | 
 | 485 |         // Parts of the linker that we're testing. | 
| Kalesh Singh | 0396f87 | 2024-02-02 22:11:08 -0800 | [diff] [blame] | 486 |         ":elf_note_sources", | 
| Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 487 |         "linker_block_allocator.cpp", | 
 | 488 |         "linker_config.cpp", | 
| Ryan Prichard | 551565e | 2019-12-23 16:03:14 -0800 | [diff] [blame] | 489 |         "linker_debug.cpp", | 
| Tamas Petz | 8d55d18 | 2020-02-24 14:15:25 +0100 | [diff] [blame] | 490 |         "linker_note_gnu_property.cpp", | 
| Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 491 |         "linker_test_globals.cpp", | 
 | 492 |         "linker_utils.cpp", | 
| Kalesh Singh | 0396f87 | 2024-02-02 22:11:08 -0800 | [diff] [blame] | 493 |         "linker_phdr.cpp", | 
 | 494 |         "linker_mapped_file_fragment.cpp", | 
 | 495 |         "linker_sdk_versions.cpp", | 
 | 496 |         "linker_dlwarning.cpp", | 
| Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 497 |     ], | 
 | 498 |  | 
 | 499 |     static_libs: [ | 
 | 500 |         "libasync_safe", | 
 | 501 |         "libbase", | 
| Jiyong Park | 7157dfb | 2022-08-19 13:09:18 +0900 | [diff] [blame] | 502 |         "liblog_for_runtime_apex", | 
| Kalesh Singh | 4084b55 | 2024-03-13 13:35:49 -0700 | [diff] [blame] | 503 |         "libprocinfo", // For procinfo::MappedFileSize() | 
| Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 504 |     ], | 
| Ryan Prichard | 129f7a1 | 2019-12-23 16:45:47 -0800 | [diff] [blame] | 505 |  | 
| Kalesh Singh | 0396f87 | 2024-02-02 22:11:08 -0800 | [diff] [blame] | 506 |     data_libs: [ | 
 | 507 |         "crt_pad_segment_disabled", | 
 | 508 |         "crt_pad_segment_enabled", | 
 | 509 |         "no_crt_pad_segment", | 
 | 510 |     ], | 
 | 511 |  | 
| Ryan Prichard | 129f7a1 | 2019-12-23 16:45:47 -0800 | [diff] [blame] | 512 |     arch: { | 
 | 513 |         arm: { | 
 | 514 |             srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"], | 
 | 515 |         }, | 
 | 516 |         arm64: { | 
 | 517 |             srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"], | 
 | 518 |         }, | 
 | 519 |     }, | 
 | 520 | } | 
 | 521 |  | 
 | 522 | cc_benchmark { | 
 | 523 |     name: "linker-benchmarks", | 
 | 524 |  | 
 | 525 |     srcs: [ | 
 | 526 |         "linker_gnu_hash_benchmark.cpp", | 
 | 527 |     ], | 
 | 528 |  | 
 | 529 |     arch: { | 
 | 530 |         arm: { | 
 | 531 |             srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"], | 
 | 532 |         }, | 
 | 533 |         arm64: { | 
 | 534 |             srcs: ["arch/arm_neon/linker_gnu_hash_neon.cpp"], | 
 | 535 |         }, | 
 | 536 |     }, | 
| Elliott Hughes | 15a2b7b | 2019-02-15 13:48:38 -0800 | [diff] [blame] | 537 | } |