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