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