Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 1 | cc_library_static { |
| 2 | name: "liblinker_malloc", |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 3 | defaults: ["linux_bionic_supported"], |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 4 | |
| 5 | srcs: [ |
| 6 | "linker_allocator.cpp", |
| 7 | "linker_memory.cpp", |
| 8 | ], |
| 9 | |
| 10 | // We need to access Bionic private headers in the linker. |
| 11 | include_dirs: ["bionic/libc"], |
Christopher Ferris | 7a3681e | 2017-04-24 17:48:32 -0700 | [diff] [blame] | 12 | |
| 13 | static_libs: ["libasync_safe"], |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | cc_binary { |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 17 | defaults: ["linux_bionic_supported"], |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 18 | srcs: [ |
| 19 | "dlfcn.cpp", |
| 20 | "linker.cpp", |
| 21 | "linker_block_allocator.cpp", |
Dimitry Ivanov | 769b33f | 2016-07-21 11:33:40 -0700 | [diff] [blame] | 22 | "linker_dlwarning.cpp", |
Evgenii Stepanov | 0a3637d | 2016-07-06 13:20:59 -0700 | [diff] [blame] | 23 | "linker_cfi.cpp", |
Dimitry Ivanov | 4cabfaa | 2017-03-07 11:19:05 -0800 | [diff] [blame] | 24 | "linker_config.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 25 | "linker_gdb_support.cpp", |
Dimitry Ivanov | 48ec288 | 2016-08-04 11:50:36 -0700 | [diff] [blame] | 26 | "linker_globals.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 27 | "linker_libc_support.c", |
Dimitry Ivanov | 451909d | 2017-01-26 16:52:59 -0800 | [diff] [blame] | 28 | "linker_libcxx_support.cpp", |
Dimitry Ivanov | 3f66057 | 2016-09-09 10:00:39 -0700 | [diff] [blame] | 29 | "linker_main.cpp", |
Dimitry Ivanov | b943f30 | 2016-08-03 16:00:10 -0700 | [diff] [blame] | 30 | "linker_namespaces.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 31 | "linker_logger.cpp", |
| 32 | "linker_mapped_file_fragment.cpp", |
| 33 | "linker_phdr.cpp", |
| 34 | "linker_sdk_versions.cpp", |
Dimitry Ivanov | 48ec288 | 2016-08-04 11:50:36 -0700 | [diff] [blame] | 35 | "linker_soinfo.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 36 | "linker_utils.cpp", |
| 37 | "rt.cpp", |
| 38 | ], |
| 39 | |
| 40 | arch: { |
| 41 | arm: { |
dimitry | 25bf29b | 2017-08-29 13:38:04 +0200 | [diff] [blame^] | 42 | srcs: [ |
| 43 | "arch/arm/begin.S", |
| 44 | "linker_exidx_static.c", |
| 45 | ], |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 46 | |
| 47 | cflags: ["-D__work_around_b_24465209__"], |
| 48 | }, |
| 49 | arm64: { |
| 50 | srcs: ["arch/arm64/begin.S"], |
| 51 | }, |
| 52 | x86: { |
| 53 | srcs: ["arch/x86/begin.c"], |
| 54 | |
| 55 | cflags: ["-D__work_around_b_24465209__"], |
| 56 | }, |
| 57 | x86_64: { |
| 58 | srcs: ["arch/x86_64/begin.S"], |
| 59 | }, |
| 60 | mips: { |
| 61 | srcs: [ |
| 62 | "arch/mips/begin.S", |
| 63 | "linker_mips.cpp", |
| 64 | ], |
| 65 | }, |
| 66 | mips64: { |
| 67 | srcs: [ |
| 68 | "arch/mips64/begin.S", |
| 69 | "linker_mips.cpp", |
| 70 | ], |
| 71 | }, |
| 72 | }, |
| 73 | |
| 74 | // We need to access Bionic private headers in the linker. |
| 75 | include_dirs: ["bionic/libc"], |
| 76 | |
| 77 | // -shared is used to overwrite the -Bstatic and -static |
| 78 | // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE. |
| 79 | // This dynamic linker is actually a shared object linked with static libraries. |
| 80 | ldflags: [ |
| 81 | "-shared", |
| 82 | "-Wl,-Bsymbolic", |
| 83 | "-Wl,--exclude-libs,ALL", |
| 84 | ], |
| 85 | |
| 86 | cflags: [ |
| 87 | "-fno-stack-protector", |
| 88 | "-Wstrict-overflow=5", |
| 89 | "-fvisibility=hidden", |
| 90 | "-Wall", |
| 91 | "-Wextra", |
| 92 | "-Wunused", |
| 93 | "-Werror", |
| 94 | ], |
| 95 | |
| 96 | // TODO: split out the asflags. |
| 97 | asflags: [ |
| 98 | "-fno-stack-protector", |
| 99 | "-Wstrict-overflow=5", |
| 100 | "-fvisibility=hidden", |
| 101 | "-Wall", |
| 102 | "-Wextra", |
| 103 | "-Wunused", |
| 104 | "-Werror", |
| 105 | ], |
| 106 | |
Jiyong Park | 02586a2 | 2017-05-20 01:01:24 +0900 | [diff] [blame] | 107 | product_variables: { |
| 108 | debuggable: { |
| 109 | cppflags: ["-DUSE_LD_CONFIG_FILE"], |
| 110 | }, |
| 111 | }, |
| 112 | |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 113 | cppflags: ["-Wold-style-cast"], |
| 114 | |
Dimitry Ivanov | fc0d480 | 2016-12-06 11:10:09 -0800 | [diff] [blame] | 115 | // we are going to link libc++_static manually because |
| 116 | // when stl is not set to "none" build system adds libdl |
| 117 | // to the list of static libraries which needs to be |
| 118 | // avoided in the case of building loader. |
| 119 | stl: "none", |
| 120 | |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 121 | // we don't want crtbegin.o (because we have begin.o), so unset it |
| 122 | // just for this module |
| 123 | nocrt: true, |
| 124 | |
| 125 | static_libs: [ |
| 126 | "libc_nomalloc", |
Dimitry Ivanov | 451909d | 2017-01-26 16:52:59 -0800 | [diff] [blame] | 127 | "libm", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 128 | "libziparchive", |
| 129 | "libutils", |
| 130 | "libbase", |
| 131 | "libz", |
Josh Gao | ec0dbc3 | 2017-02-08 17:27:20 -0800 | [diff] [blame] | 132 | |
Josh Gao | ec0dbc3 | 2017-02-08 17:27:20 -0800 | [diff] [blame] | 133 | "libdebuggerd_handler_fallback", |
Josh Gao | ec0dbc3 | 2017-02-08 17:27:20 -0800 | [diff] [blame] | 134 | |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 135 | "liblog", |
Dimitry Ivanov | fc0d480 | 2016-12-06 11:10:09 -0800 | [diff] [blame] | 136 | "libc++_static", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 137 | |
| 138 | // Important: The liblinker_malloc should be the last library in the list |
| 139 | // to overwrite any other malloc implementations by other static libraries. |
| 140 | "liblinker_malloc" |
| 141 | ], |
| 142 | static_executable: true, |
| 143 | |
| 144 | name: "linker", |
Colin Cross | 10fffb4 | 2016-12-08 09:57:35 -0800 | [diff] [blame] | 145 | symlinks: ["linker_asan"], |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 146 | multilib: { |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 147 | lib64: { |
| 148 | suffix: "64", |
Colin Cross | 10fffb4 | 2016-12-08 09:57:35 -0800 | [diff] [blame] | 149 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 150 | }, |
| 151 | target: { |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 152 | android: { |
| 153 | static_libs: ["libdebuggerd_client"], |
| 154 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 155 | android64: { |
| 156 | cflags: ["-DTARGET_IS_64_BIT"], |
| 157 | }, |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 158 | linux_bionic: { |
| 159 | cflags: ["-DTARGET_IS_64_BIT"], |
| 160 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 161 | }, |
| 162 | compile_multilib: "both", |
| 163 | |
| 164 | // Leave the symbols in the shared library so that stack unwinders can produce |
| 165 | // meaningful name resolution. |
| 166 | strip: { |
| 167 | keep_symbols: true, |
| 168 | }, |
| 169 | |
| 170 | // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb |
| 171 | // looking up symbols in the linker by mistake. |
| 172 | prefix_symbols: "__dl_", |
| 173 | } |