Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 1 | cc_library_static { |
| 2 | name: "liblinker_malloc", |
Andreas Gampe | dcb846c | 2016-12-06 02:10:13 +0000 | [diff] [blame] | 3 | clang: true, |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 4 | defaults: ["linux_bionic_supported"], |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 5 | |
| 6 | srcs: [ |
| 7 | "linker_allocator.cpp", |
| 8 | "linker_memory.cpp", |
| 9 | ], |
| 10 | |
| 11 | // We need to access Bionic private headers in the linker. |
| 12 | include_dirs: ["bionic/libc"], |
| 13 | } |
| 14 | |
| 15 | cc_binary { |
Andreas Gampe | dcb846c | 2016-12-06 02:10:13 +0000 | [diff] [blame] | 16 | clang: true, |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 17 | defaults: ["linux_bionic_supported"], |
Andreas Gampe | dcb846c | 2016-12-06 02:10:13 +0000 | [diff] [blame] | 18 | |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 19 | srcs: [ |
| 20 | "dlfcn.cpp", |
| 21 | "linker.cpp", |
| 22 | "linker_block_allocator.cpp", |
Dimitry Ivanov | 769b33f | 2016-07-21 11:33:40 -0700 | [diff] [blame] | 23 | "linker_dlwarning.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 24 | "linker_gdb_support.cpp", |
Dimitry Ivanov | 48ec288 | 2016-08-04 11:50:36 -0700 | [diff] [blame] | 25 | "linker_globals.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 26 | "linker_libc_support.c", |
Dimitry Ivanov | 3f66057 | 2016-09-09 10:00:39 -0700 | [diff] [blame] | 27 | "linker_main.cpp", |
Dimitry Ivanov | b943f30 | 2016-08-03 16:00:10 -0700 | [diff] [blame] | 28 | "linker_namespaces.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 29 | "linker_logger.cpp", |
| 30 | "linker_mapped_file_fragment.cpp", |
| 31 | "linker_phdr.cpp", |
| 32 | "linker_sdk_versions.cpp", |
Dimitry Ivanov | 48ec288 | 2016-08-04 11:50:36 -0700 | [diff] [blame] | 33 | "linker_soinfo.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 34 | "linker_utils.cpp", |
| 35 | "rt.cpp", |
| 36 | ], |
| 37 | |
| 38 | arch: { |
| 39 | arm: { |
| 40 | srcs: ["arch/arm/begin.S"], |
| 41 | |
| 42 | cflags: ["-D__work_around_b_24465209__"], |
| 43 | }, |
| 44 | arm64: { |
| 45 | srcs: ["arch/arm64/begin.S"], |
| 46 | }, |
| 47 | x86: { |
| 48 | srcs: ["arch/x86/begin.c"], |
| 49 | |
| 50 | cflags: ["-D__work_around_b_24465209__"], |
| 51 | }, |
| 52 | x86_64: { |
| 53 | srcs: ["arch/x86_64/begin.S"], |
| 54 | }, |
| 55 | mips: { |
| 56 | srcs: [ |
| 57 | "arch/mips/begin.S", |
| 58 | "linker_mips.cpp", |
| 59 | ], |
| 60 | }, |
| 61 | mips64: { |
| 62 | srcs: [ |
| 63 | "arch/mips64/begin.S", |
| 64 | "linker_mips.cpp", |
| 65 | ], |
| 66 | }, |
| 67 | }, |
| 68 | |
| 69 | // We need to access Bionic private headers in the linker. |
| 70 | include_dirs: ["bionic/libc"], |
| 71 | |
| 72 | // -shared is used to overwrite the -Bstatic and -static |
| 73 | // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE. |
| 74 | // This dynamic linker is actually a shared object linked with static libraries. |
| 75 | ldflags: [ |
| 76 | "-shared", |
| 77 | "-Wl,-Bsymbolic", |
| 78 | "-Wl,--exclude-libs,ALL", |
| 79 | ], |
| 80 | |
| 81 | cflags: [ |
| 82 | "-fno-stack-protector", |
| 83 | "-Wstrict-overflow=5", |
| 84 | "-fvisibility=hidden", |
| 85 | "-Wall", |
| 86 | "-Wextra", |
| 87 | "-Wunused", |
| 88 | "-Werror", |
| 89 | ], |
| 90 | |
| 91 | // TODO: split out the asflags. |
| 92 | asflags: [ |
| 93 | "-fno-stack-protector", |
| 94 | "-Wstrict-overflow=5", |
| 95 | "-fvisibility=hidden", |
| 96 | "-Wall", |
| 97 | "-Wextra", |
| 98 | "-Wunused", |
| 99 | "-Werror", |
| 100 | ], |
| 101 | |
Andreas Gampe | dcb846c | 2016-12-06 02:10:13 +0000 | [diff] [blame] | 102 | conlyflags: ["-std=gnu99"], |
| 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", |
| 118 | "libziparchive", |
| 119 | "libutils", |
| 120 | "libbase", |
| 121 | "libz", |
| 122 | "liblog", |
Dimitry Ivanov | fc0d480 | 2016-12-06 11:10:09 -0800 | [diff] [blame] | 123 | "libc++_static", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 124 | |
| 125 | // Important: The liblinker_malloc should be the last library in the list |
| 126 | // to overwrite any other malloc implementations by other static libraries. |
| 127 | "liblinker_malloc" |
| 128 | ], |
| 129 | static_executable: true, |
| 130 | |
| 131 | name: "linker", |
Colin Cross | 10fffb4 | 2016-12-08 09:57:35 -0800 | [diff] [blame^] | 132 | symlinks: ["linker_asan"], |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 133 | multilib: { |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 134 | lib64: { |
| 135 | suffix: "64", |
Colin Cross | 10fffb4 | 2016-12-08 09:57:35 -0800 | [diff] [blame^] | 136 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 137 | }, |
| 138 | target: { |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 139 | android: { |
| 140 | static_libs: ["libdebuggerd_client"], |
| 141 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 142 | android64: { |
| 143 | cflags: ["-DTARGET_IS_64_BIT"], |
| 144 | }, |
Dan Willemsen | 7ec52b1 | 2016-11-28 17:02:25 -0800 | [diff] [blame] | 145 | linux_bionic: { |
| 146 | cflags: ["-DTARGET_IS_64_BIT"], |
| 147 | }, |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 148 | }, |
| 149 | compile_multilib: "both", |
| 150 | |
| 151 | // Leave the symbols in the shared library so that stack unwinders can produce |
| 152 | // meaningful name resolution. |
| 153 | strip: { |
| 154 | keep_symbols: true, |
| 155 | }, |
| 156 | |
| 157 | // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb |
| 158 | // looking up symbols in the linker by mistake. |
| 159 | prefix_symbols: "__dl_", |
| 160 | } |