| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 1 | // | 
|  | 2 | // libdl | 
|  | 3 | // | 
| Bob Badour | aa7d835 | 2021-02-19 13:06:22 -0800 | [diff] [blame] | 4 | package { | 
|  | 5 | default_applicable_licenses: ["bionic_libdl_license"], | 
|  | 6 | } | 
|  | 7 |  | 
|  | 8 | license { | 
|  | 9 | name: "bionic_libdl_license", | 
|  | 10 | visibility: [":__subpackages__"], | 
|  | 11 | license_kinds: [ | 
|  | 12 | "SPDX-license-identifier-Apache-2.0", | 
|  | 13 | ], | 
|  | 14 | license_text: [ | 
|  | 15 | "NOTICE", | 
|  | 16 | ], | 
|  | 17 | } | 
|  | 18 |  | 
| dimitry | c5ea3eb | 2017-10-05 17:23:10 +0200 | [diff] [blame] | 19 | cc_library_static { | 
|  | 20 | name: "libdl_static", | 
| Dan Willemsen | 17b3559 | 2018-10-11 23:32:26 -0700 | [diff] [blame] | 21 | defaults: ["linux_bionic_supported"], | 
| Yifan Hong | 5a39cee | 2020-01-21 16:43:56 -0800 | [diff] [blame] | 22 | ramdisk_available: true, | 
| Yifan Hong | b04490d | 2020-10-21 18:36:36 -0700 | [diff] [blame] | 23 | vendor_ramdisk_available: true, | 
| Jiyong Park | 5603c6e | 2018-04-27 21:53:11 +0900 | [diff] [blame] | 24 | recovery_available: true, | 
| dimitry | 7f04880 | 2019-05-03 15:57:34 +0200 | [diff] [blame] | 25 | native_bridge_supported: true, | 
| dimitry | c5ea3eb | 2017-10-05 17:23:10 +0200 | [diff] [blame] | 26 |  | 
| Elliott Hughes | d50a1de | 2018-02-05 17:30:57 -0800 | [diff] [blame] | 27 | srcs: [ | 
|  | 28 | "libdl.cpp", | 
|  | 29 | "libdl_cfi.cpp", | 
|  | 30 | ], | 
| dimitry | c5ea3eb | 2017-10-05 17:23:10 +0200 | [diff] [blame] | 31 |  | 
|  | 32 | cflags: [ | 
|  | 33 | "-Wall", | 
|  | 34 | "-Wextra", | 
|  | 35 | "-Wunused", | 
|  | 36 | "-Werror", | 
|  | 37 | ], | 
|  | 38 |  | 
|  | 39 | // For private/CFIShadow.h. | 
|  | 40 | include_dirs: ["bionic/libc"], | 
|  | 41 |  | 
|  | 42 | stl: "none", | 
| Dan Willemsen | 6b3be17 | 2018-12-03 13:57:20 -0800 | [diff] [blame] | 43 | system_shared_libs: [], | 
| Martin Stjernholm | 82d84bc | 2020-04-06 20:32:09 +0100 | [diff] [blame] | 44 | header_libs: ["libc_headers"], | 
| Martin Stjernholm | 3ddcc1e | 2020-05-06 23:44:08 +0100 | [diff] [blame] | 45 | export_header_lib_headers: ["libc_headers"], | 
| dimitry | c5ea3eb | 2017-10-05 17:23:10 +0200 | [diff] [blame] | 46 |  | 
|  | 47 | sanitize: { | 
|  | 48 | never: true, | 
|  | 49 | }, | 
|  | 50 | } | 
|  | 51 |  | 
| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 52 | cc_library { | 
| Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 53 | name: "libdl", | 
| Yifan Hong | 5a39cee | 2020-01-21 16:43:56 -0800 | [diff] [blame] | 54 | ramdisk_available: true, | 
| Yifan Hong | b04490d | 2020-10-21 18:36:36 -0700 | [diff] [blame] | 55 | vendor_ramdisk_available: true, | 
| Jiyong Park | 5603c6e | 2018-04-27 21:53:11 +0900 | [diff] [blame] | 56 | recovery_available: true, | 
| dimitry | 7f04880 | 2019-05-03 15:57:34 +0200 | [diff] [blame] | 57 | native_bridge_supported: true, | 
| Dan Albert | 40f15ec | 2017-10-27 11:21:20 -0700 | [diff] [blame] | 58 | static_ndk_lib: true, | 
| Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 59 |  | 
|  | 60 | defaults: ["linux_bionic_supported"], | 
| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 61 |  | 
|  | 62 | // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from | 
|  | 63 | // libgcc.a are made static to libdl.so.  This in turn ensures that libraries that | 
|  | 64 | // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so | 
|  | 65 | // to provide those symbols, but will instead pull them from libgcc.a.  Specifically, | 
|  | 66 | // we use this property to make sure libc.so has its own copy of the code from | 
|  | 67 | // libgcc.a it uses. | 
|  | 68 | // | 
|  | 69 | // DO NOT REMOVE --exclude-libs! | 
|  | 70 |  | 
| Yi Kong | 7786a34 | 2018-08-31 19:01:56 -0700 | [diff] [blame] | 71 | ldflags: [ | 
|  | 72 | "-Wl,--exclude-libs=libgcc.a", | 
| Yi Kong | 7ac2afb | 2019-05-06 16:23:10 -0700 | [diff] [blame] | 73 | "-Wl,--exclude-libs=libgcc_stripped.a", | 
| Yi Kong | 7786a34 | 2018-08-31 19:01:56 -0700 | [diff] [blame] | 74 | "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a", | 
|  | 75 | "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a", | 
| Ryan Prichard | ef14787 | 2021-01-28 14:06:52 -0800 | [diff] [blame] | 76 | "-Wl,--exclude-libs=libclang_rt.builtins-i686-android.a", | 
| Yi Kong | 7786a34 | 2018-08-31 19:01:56 -0700 | [diff] [blame] | 77 | "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a", | 
|  | 78 | ], | 
| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 79 |  | 
|  | 80 | // for x86, exclude libgcc_eh.a for the same reasons as above | 
|  | 81 | arch: { | 
| Dan Willemsen | 9e6f98f | 2015-11-03 14:30:57 -0800 | [diff] [blame] | 82 | arm: { | 
| Elliott Hughes | d19b3c5 | 2018-09-06 16:04:08 -0700 | [diff] [blame] | 83 | version_script: ":libdl.arm.map", | 
| Chih-Hung Hsieh | ecbff83 | 2018-05-23 18:45:53 -0700 | [diff] [blame] | 84 | pack_relocations: false, | 
| Ian Pedowitz | b6310c2 | 2018-01-18 16:26:19 -0800 | [diff] [blame] | 85 | ldflags: ["-Wl,--hash-style=both"], | 
| Dan Willemsen | 9e6f98f | 2015-11-03 14:30:57 -0800 | [diff] [blame] | 86 | }, | 
|  | 87 | arm64: { | 
| Elliott Hughes | d19b3c5 | 2018-09-06 16:04:08 -0700 | [diff] [blame] | 88 | version_script: ":libdl.arm64.map", | 
| Dan Willemsen | 9e6f98f | 2015-11-03 14:30:57 -0800 | [diff] [blame] | 89 | }, | 
| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 90 | x86: { | 
| Chih-Hung Hsieh | ecbff83 | 2018-05-23 18:45:53 -0700 | [diff] [blame] | 91 | pack_relocations: false, | 
| Dimitry Ivanov | ac4bd2f | 2016-11-21 12:50:38 -0800 | [diff] [blame] | 92 | ldflags: [ | 
|  | 93 | "-Wl,--exclude-libs=libgcc_eh.a", | 
| Ian Pedowitz | b6310c2 | 2018-01-18 16:26:19 -0800 | [diff] [blame] | 94 | "-Wl,--hash-style=both", | 
| Dimitry Ivanov | ac4bd2f | 2016-11-21 12:50:38 -0800 | [diff] [blame] | 95 | ], | 
| Elliott Hughes | d19b3c5 | 2018-09-06 16:04:08 -0700 | [diff] [blame] | 96 | version_script: ":libdl.x86.map", | 
| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 97 | }, | 
|  | 98 | x86_64: { | 
|  | 99 | ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"], | 
| Elliott Hughes | d19b3c5 | 2018-09-06 16:04:08 -0700 | [diff] [blame] | 100 | version_script: ":libdl.x86_64.map", | 
| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 101 | }, | 
|  | 102 | }, | 
| dimitry | dc7cc62 | 2017-08-30 10:52:19 +0200 | [diff] [blame] | 103 | shared: { | 
| dimitry | c5ea3eb | 2017-10-05 17:23:10 +0200 | [diff] [blame] | 104 | whole_static_libs: ["libdl_static"], | 
| dimitry | dc7cc62 | 2017-08-30 10:52:19 +0200 | [diff] [blame] | 105 | }, | 
|  | 106 | static: { | 
| Elliott Hughes | 46a943c | 2018-04-03 15:56:35 -0700 | [diff] [blame] | 107 | srcs: ["libdl_static.cpp"], | 
| dimitry | dc7cc62 | 2017-08-30 10:52:19 +0200 | [diff] [blame] | 108 | }, | 
| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 109 | cflags: [ | 
|  | 110 | "-Wall", | 
|  | 111 | "-Wextra", | 
|  | 112 | "-Wunused", | 
|  | 113 | "-Werror", | 
|  | 114 | ], | 
|  | 115 | stl: "none", | 
|  | 116 |  | 
| Ryan Prichard | 470b666 | 2018-03-27 22:10:55 -0700 | [diff] [blame] | 117 | nocrt: true, | 
| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 118 | system_shared_libs: [], | 
| Martin Stjernholm | 82d84bc | 2020-04-06 20:32:09 +0100 | [diff] [blame] | 119 | header_libs: ["libc_headers"], | 
| Pirama Arumuga Nainar | eeb2ee6 | 2019-02-15 11:40:40 -0800 | [diff] [blame] | 120 |  | 
|  | 121 | // Opt out of native_coverage when opting out of system_shared_libs | 
| Pirama Arumuga Nainar | 852d523 | 2018-12-20 13:52:19 -0800 | [diff] [blame] | 122 | native_coverage: false, | 
| Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 123 |  | 
| Dimitry Ivanov | d9e427c | 2016-11-22 16:55:25 -0800 | [diff] [blame] | 124 | // This is placeholder library the actual implementation is (currently) | 
|  | 125 | // provided by the linker. | 
| Elliott Hughes | d50a1de | 2018-02-05 17:30:57 -0800 | [diff] [blame] | 126 | shared_libs: ["ld-android"], | 
| Dimitry Ivanov | d9e427c | 2016-11-22 16:55:25 -0800 | [diff] [blame] | 127 |  | 
|  | 128 | sanitize: { | 
|  | 129 | never: true, | 
|  | 130 | }, | 
| Jiyong Park | c45fe9f | 2018-12-13 18:26:48 +0900 | [diff] [blame] | 131 |  | 
|  | 132 | stubs: { | 
|  | 133 | symbol_file: "libdl.map.txt", | 
| Jooyung Han | 26ddc4d | 2020-02-27 18:33:25 +0900 | [diff] [blame] | 134 | versions: [ | 
|  | 135 | "29", | 
| Dan Albert | 48943b2 | 2020-07-27 13:28:56 -0700 | [diff] [blame] | 136 | "current", | 
| Jooyung Han | 26ddc4d | 2020-02-27 18:33:25 +0900 | [diff] [blame] | 137 | ], | 
| Jiyong Park | c45fe9f | 2018-12-13 18:26:48 +0900 | [diff] [blame] | 138 | }, | 
| Colin Cross | a0a4a6c | 2021-03-02 10:23:04 -0800 | [diff] [blame] | 139 | llndk: { | 
|  | 140 | symbol_file: "libdl.map.txt", | 
|  | 141 | }, | 
| Jiyong Park | e87e0dc | 2019-10-02 17:09:33 +0900 | [diff] [blame] | 142 |  | 
|  | 143 | apex_available: [ | 
|  | 144 | "//apex_available:platform", | 
|  | 145 | "com.android.runtime", | 
|  | 146 | ], | 
| Yi Kong | 15a05a7 | 2020-09-22 00:56:13 +0800 | [diff] [blame] | 147 |  | 
|  | 148 | lto: { | 
|  | 149 | never: true, | 
|  | 150 | }, | 
| Dimitry Ivanov | d9e427c | 2016-11-22 16:55:25 -0800 | [diff] [blame] | 151 | } | 
|  | 152 |  | 
| dimitry | 8868d9e | 2019-03-19 13:01:42 +0100 | [diff] [blame] | 153 | cc_library { | 
|  | 154 | name: "libdl_android", | 
|  | 155 |  | 
|  | 156 | defaults: ["linux_bionic_supported"], | 
| Yifan Hong | 5a39cee | 2020-01-21 16:43:56 -0800 | [diff] [blame] | 157 | ramdisk_available: true, | 
| Yifan Hong | b04490d | 2020-10-21 18:36:36 -0700 | [diff] [blame] | 158 | vendor_ramdisk_available: true, | 
| Jiyong Park | 3ff116a | 2019-04-02 23:04:52 +0900 | [diff] [blame] | 159 | recovery_available: true, | 
| dimitry | 7f04880 | 2019-05-03 15:57:34 +0200 | [diff] [blame] | 160 | native_bridge_supported: true, | 
| dimitry | 8868d9e | 2019-03-19 13:01:42 +0100 | [diff] [blame] | 161 |  | 
|  | 162 | // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from | 
|  | 163 | // libgcc.a are made static to libdl.so.  This in turn ensures that libraries that | 
|  | 164 | // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so | 
|  | 165 | // to provide those symbols, but will instead pull them from libgcc.a.  Specifically, | 
|  | 166 | // we use this property to make sure libc.so has its own copy of the code from | 
|  | 167 | // libgcc.a it uses. | 
|  | 168 | // | 
|  | 169 | // DO NOT REMOVE --exclude-libs! | 
|  | 170 |  | 
|  | 171 | ldflags: [ | 
|  | 172 | "-Wl,--exclude-libs=libgcc.a", | 
| Yi Kong | 7ac2afb | 2019-05-06 16:23:10 -0700 | [diff] [blame] | 173 | "-Wl,--exclude-libs=libgcc_stripped.a", | 
| dimitry | 8868d9e | 2019-03-19 13:01:42 +0100 | [diff] [blame] | 174 | "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a", | 
|  | 175 | "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a", | 
| Ryan Prichard | ef14787 | 2021-01-28 14:06:52 -0800 | [diff] [blame] | 176 | "-Wl,--exclude-libs=libclang_rt.builtins-i686-android.a", | 
| dimitry | 8868d9e | 2019-03-19 13:01:42 +0100 | [diff] [blame] | 177 | "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a", | 
|  | 178 | ], | 
|  | 179 |  | 
|  | 180 | // for x86, exclude libgcc_eh.a for the same reasons as above | 
|  | 181 | arch: { | 
|  | 182 | x86: { | 
|  | 183 | ldflags: [ | 
|  | 184 | "-Wl,--exclude-libs=libgcc_eh.a", | 
|  | 185 | ], | 
|  | 186 | }, | 
|  | 187 | x86_64: { | 
|  | 188 | ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"], | 
|  | 189 | }, | 
|  | 190 | }, | 
|  | 191 |  | 
|  | 192 | srcs: [ "libdl_android.cpp" ], | 
|  | 193 | version_script: "libdl_android.map.txt", | 
|  | 194 |  | 
|  | 195 | cflags: [ | 
|  | 196 | "-Wall", | 
|  | 197 | "-Wextra", | 
|  | 198 | "-Wunused", | 
|  | 199 | "-Werror", | 
|  | 200 | ], | 
|  | 201 |  | 
|  | 202 | stl: "none", | 
|  | 203 |  | 
|  | 204 | nocrt: true, | 
|  | 205 | system_shared_libs: [], | 
| Martin Stjernholm | 82d84bc | 2020-04-06 20:32:09 +0100 | [diff] [blame] | 206 | header_libs: ["libc_headers"], | 
| dimitry | 8868d9e | 2019-03-19 13:01:42 +0100 | [diff] [blame] | 207 |  | 
|  | 208 | // Opt out of native_coverage when opting out of system_shared_libs | 
|  | 209 | native_coverage: false, | 
|  | 210 |  | 
|  | 211 | // This is placeholder library the actual implementation is (currently) | 
|  | 212 | // provided by the linker. | 
|  | 213 | shared_libs: ["ld-android"], | 
|  | 214 |  | 
|  | 215 | sanitize: { | 
|  | 216 | never: true, | 
|  | 217 | }, | 
|  | 218 |  | 
|  | 219 | stubs: { | 
|  | 220 | symbol_file: "libdl_android.map.txt", | 
| Dan Albert | 48943b2 | 2020-07-27 13:28:56 -0700 | [diff] [blame] | 221 | versions: ["current"], | 
| dimitry | 8868d9e | 2019-03-19 13:01:42 +0100 | [diff] [blame] | 222 | }, | 
| Martin Stjernholm | 3274cc4 | 2019-11-11 15:33:22 +0000 | [diff] [blame] | 223 |  | 
|  | 224 | apex_available: [ | 
|  | 225 | "//apex_available:platform", | 
|  | 226 | "com.android.runtime", | 
|  | 227 | ], | 
| Yi Kong | 15a05a7 | 2020-09-22 00:56:13 +0800 | [diff] [blame] | 228 |  | 
|  | 229 | lto: { | 
|  | 230 | never: true, | 
|  | 231 | }, | 
| dimitry | 8868d9e | 2019-03-19 13:01:42 +0100 | [diff] [blame] | 232 | } | 
|  | 233 |  | 
| Dan Albert | e8a9108 | 2016-08-04 13:45:44 -0700 | [diff] [blame] | 234 | ndk_library { | 
| Dan Willemsen | 993b083 | 2017-04-07 14:09:18 -0700 | [diff] [blame] | 235 | name: "libdl", | 
| Dan Albert | e8a9108 | 2016-08-04 13:45:44 -0700 | [diff] [blame] | 236 | symbol_file: "libdl.map.txt", | 
|  | 237 | first_version: "9", | 
|  | 238 | } | 
| Dan Willemsen | b93d3c2 | 2017-03-20 14:07:47 -0700 | [diff] [blame] | 239 |  | 
| Elliott Hughes | d19b3c5 | 2018-09-06 16:04:08 -0700 | [diff] [blame] | 240 | genrule { | 
|  | 241 | name: "libdl.arm.map", | 
|  | 242 | out: ["libdl.arm.map"], | 
|  | 243 | srcs: ["libdl.map.txt"], | 
|  | 244 | tool_files: [":bionic-generate-version-script"], | 
|  | 245 | cmd: "$(location :bionic-generate-version-script) arm $(in) $(out)", | 
|  | 246 | } | 
|  | 247 |  | 
|  | 248 | genrule { | 
|  | 249 | name: "libdl.arm64.map", | 
|  | 250 | out: ["libdl.arm64.map"], | 
|  | 251 | srcs: ["libdl.map.txt"], | 
|  | 252 | tool_files: [":bionic-generate-version-script"], | 
|  | 253 | cmd: "$(location :bionic-generate-version-script) arm64 $(in) $(out)", | 
|  | 254 | } | 
|  | 255 |  | 
|  | 256 | genrule { | 
|  | 257 | name: "libdl.x86.map", | 
|  | 258 | out: ["libdl.x86.map"], | 
|  | 259 | srcs: ["libdl.map.txt"], | 
|  | 260 | tool_files: [":bionic-generate-version-script"], | 
|  | 261 | cmd: "$(location :bionic-generate-version-script) x86 $(in) $(out)", | 
|  | 262 | } | 
|  | 263 |  | 
|  | 264 | genrule { | 
|  | 265 | name: "libdl.x86_64.map", | 
|  | 266 | out: ["libdl.x86_64.map"], | 
|  | 267 | srcs: ["libdl.map.txt"], | 
|  | 268 | tool_files: [":bionic-generate-version-script"], | 
|  | 269 | cmd: "$(location :bionic-generate-version-script) x86_64 $(in) $(out)", | 
|  | 270 | } |