Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 1 | // |
| 2 | // libdl |
| 3 | // |
| 4 | cc_library { |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 5 | name: "libdl", |
| 6 | |
| 7 | defaults: ["linux_bionic_supported"], |
Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 8 | |
| 9 | // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from |
| 10 | // libgcc.a are made static to libdl.so. This in turn ensures that libraries that |
| 11 | // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so |
| 12 | // to provide those symbols, but will instead pull them from libgcc.a. Specifically, |
| 13 | // we use this property to make sure libc.so has its own copy of the code from |
| 14 | // libgcc.a it uses. |
| 15 | // |
| 16 | // DO NOT REMOVE --exclude-libs! |
| 17 | |
| 18 | ldflags: ["-Wl,--exclude-libs=libgcc.a"], |
Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 19 | |
| 20 | // for x86, exclude libgcc_eh.a for the same reasons as above |
| 21 | arch: { |
Dan Willemsen | 9e6f98f | 2015-11-03 14:30:57 -0800 | [diff] [blame] | 22 | arm: { |
| 23 | version_script: "libdl.arm.map", |
| 24 | }, |
| 25 | arm64: { |
| 26 | version_script: "libdl.arm64.map", |
| 27 | }, |
| 28 | mips: { |
| 29 | version_script: "libdl.mips.map", |
| 30 | }, |
| 31 | mips64: { |
| 32 | version_script: "libdl.mips64.map", |
| 33 | }, |
Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 34 | x86: { |
| 35 | ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"], |
Dan Willemsen | 9e6f98f | 2015-11-03 14:30:57 -0800 | [diff] [blame] | 36 | version_script: "libdl.x86.map", |
Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 37 | }, |
| 38 | x86_64: { |
| 39 | ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"], |
Dan Willemsen | 9e6f98f | 2015-11-03 14:30:57 -0800 | [diff] [blame] | 40 | version_script: "libdl.x86_64.map", |
Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 41 | }, |
| 42 | }, |
| 43 | srcs: ["libdl.c"], |
| 44 | cflags: [ |
| 45 | "-Wall", |
| 46 | "-Wextra", |
| 47 | "-Wunused", |
| 48 | "-Werror", |
| 49 | ], |
| 50 | stl: "none", |
| 51 | |
Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 52 | // NOTE: libdl needs __aeabi_unwind_cpp_pr0 from libgcc.a but libgcc.a needs a |
| 53 | // few symbols from libc. Using --no-undefined here results in having to link |
| 54 | // against libc creating a circular dependency which is removed and we end up |
| 55 | // with missing symbols. Since this library is just a bunch of stubs, we set |
| 56 | // LOCAL_ALLOW_UNDEFINED_SYMBOLS to remove --no-undefined from the linker flags. |
| 57 | allow_undefined_symbols: true, |
| 58 | system_shared_libs: [], |
| 59 | |
Dimitry Ivanov | d9e427c | 2016-11-22 16:55:25 -0800 | [diff] [blame^] | 60 | // This is placeholder library the actual implementation is (currently) |
| 61 | // provided by the linker. |
| 62 | shared_libs: [ "ld-android" ], |
| 63 | |
| 64 | sanitize: { |
| 65 | never: true, |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | cc_library { |
| 70 | // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from |
| 71 | // libgcc.a are made static to ld-android.so. This in turn ensures that libraries that |
| 72 | // a) pull symbols from libgcc.a and b) depend on ld-android.so will not rely on ld-android.so |
| 73 | // to provide those symbols, but will instead pull them from libgcc.a. Specifically, |
| 74 | // we use this property to make sure libc.so has its own copy of the code from |
| 75 | // libgcc.a it uses. |
| 76 | // |
| 77 | // DO NOT REMOVE --exclude-libs! |
| 78 | |
| 79 | ldflags: ["-Wl,--exclude-libs=libgcc.a"], |
| 80 | |
| 81 | // for x86, exclude libgcc_eh.a for the same reasons as above |
| 82 | arch: { |
| 83 | x86: { |
| 84 | ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"], |
| 85 | }, |
| 86 | x86_64: { |
| 87 | ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"], |
| 88 | }, |
| 89 | }, |
| 90 | srcs: ["ld_android.c"], |
| 91 | cflags: [ |
| 92 | "-Wall", |
| 93 | "-Wextra", |
| 94 | "-Wunused", |
| 95 | "-Werror", |
| 96 | ], |
| 97 | stl: "none", |
| 98 | |
| 99 | name: "ld-android", |
| 100 | |
| 101 | // NOTE: libdl needs __aeabi_unwind_cpp_pr0 from libgcc.a but libgcc.a needs a |
| 102 | // few symbols from libc. Using --no-undefined here results in having to link |
| 103 | // against libc creating a circular dependency which is removed and we end up |
| 104 | // with missing symbols. Since this library is just a bunch of stubs, we set |
| 105 | // LOCAL_ALLOW_UNDEFINED_SYMBOLS to remove --no-undefined from the linker flags. |
| 106 | allow_undefined_symbols: true, |
| 107 | system_shared_libs: [], |
| 108 | |
Colin Cross | 27c43c5 | 2016-04-07 13:27:24 -0700 | [diff] [blame] | 109 | sanitize: { |
| 110 | never: true, |
| 111 | }, |
Dan Willemsen | 208ae17 | 2015-09-16 16:33:27 -0700 | [diff] [blame] | 112 | } |
Dan Albert | e8a9108 | 2016-08-04 13:45:44 -0700 | [diff] [blame] | 113 | |
| 114 | ndk_library { |
| 115 | name: "libdl.ndk", |
| 116 | symbol_file: "libdl.map.txt", |
| 117 | first_version: "9", |
| 118 | } |