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