Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 1 | cc_library_static { |
| 2 | name: "liblinker_malloc", |
| 3 | clang: true, |
| 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 { |
| 15 | clang: true, |
| 16 | |
| 17 | srcs: [ |
| 18 | "dlfcn.cpp", |
| 19 | "linker.cpp", |
| 20 | "linker_block_allocator.cpp", |
Dimitry Ivanov | 769b33f | 2016-07-21 11:33:40 -0700 | [diff] [blame] | 21 | "linker_dlwarning.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 | b943f30 | 2016-08-03 16:00:10 -0700 | [diff] [blame] | 25 | "linker_namespaces.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 26 | "linker_logger.cpp", |
| 27 | "linker_mapped_file_fragment.cpp", |
| 28 | "linker_phdr.cpp", |
| 29 | "linker_sdk_versions.cpp", |
Dimitry Ivanov | 48ec288 | 2016-08-04 11:50:36 -0700 | [diff] [blame^] | 30 | "linker_soinfo.cpp", |
Colin Cross | 97f0aef | 2016-07-14 16:05:46 -0700 | [diff] [blame] | 31 | "linker_utils.cpp", |
| 32 | "rt.cpp", |
| 33 | ], |
| 34 | |
| 35 | arch: { |
| 36 | arm: { |
| 37 | srcs: ["arch/arm/begin.S"], |
| 38 | |
| 39 | cflags: ["-D__work_around_b_24465209__"], |
| 40 | }, |
| 41 | arm64: { |
| 42 | srcs: ["arch/arm64/begin.S"], |
| 43 | }, |
| 44 | x86: { |
| 45 | srcs: ["arch/x86/begin.c"], |
| 46 | |
| 47 | cflags: ["-D__work_around_b_24465209__"], |
| 48 | }, |
| 49 | x86_64: { |
| 50 | srcs: ["arch/x86_64/begin.S"], |
| 51 | }, |
| 52 | mips: { |
| 53 | srcs: [ |
| 54 | "arch/mips/begin.S", |
| 55 | "linker_mips.cpp", |
| 56 | ], |
| 57 | }, |
| 58 | mips64: { |
| 59 | srcs: [ |
| 60 | "arch/mips64/begin.S", |
| 61 | "linker_mips.cpp", |
| 62 | ], |
| 63 | }, |
| 64 | }, |
| 65 | |
| 66 | // We need to access Bionic private headers in the linker. |
| 67 | include_dirs: ["bionic/libc"], |
| 68 | |
| 69 | // -shared is used to overwrite the -Bstatic and -static |
| 70 | // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE. |
| 71 | // This dynamic linker is actually a shared object linked with static libraries. |
| 72 | ldflags: [ |
| 73 | "-shared", |
| 74 | "-Wl,-Bsymbolic", |
| 75 | "-Wl,--exclude-libs,ALL", |
| 76 | ], |
| 77 | |
| 78 | cflags: [ |
| 79 | "-fno-stack-protector", |
| 80 | "-Wstrict-overflow=5", |
| 81 | "-fvisibility=hidden", |
| 82 | "-Wall", |
| 83 | "-Wextra", |
| 84 | "-Wunused", |
| 85 | "-Werror", |
| 86 | ], |
| 87 | |
| 88 | // TODO: split out the asflags. |
| 89 | asflags: [ |
| 90 | "-fno-stack-protector", |
| 91 | "-Wstrict-overflow=5", |
| 92 | "-fvisibility=hidden", |
| 93 | "-Wall", |
| 94 | "-Wextra", |
| 95 | "-Wunused", |
| 96 | "-Werror", |
| 97 | ], |
| 98 | |
| 99 | conlyflags: ["-std=gnu99"], |
| 100 | |
| 101 | cppflags: ["-Wold-style-cast"], |
| 102 | |
| 103 | // we don't want crtbegin.o (because we have begin.o), so unset it |
| 104 | // just for this module |
| 105 | nocrt: true, |
| 106 | |
| 107 | static_libs: [ |
| 108 | "libc_nomalloc", |
| 109 | "libziparchive", |
| 110 | "libutils", |
| 111 | "libbase", |
| 112 | "libz", |
| 113 | "liblog", |
| 114 | "libdebuggerd_client", |
| 115 | |
| 116 | // Important: The liblinker_malloc should be the last library in the list |
| 117 | // to overwrite any other malloc implementations by other static libraries. |
| 118 | "liblinker_malloc" |
| 119 | ], |
| 120 | static_executable: true, |
| 121 | |
| 122 | name: "linker", |
| 123 | multilib: { |
| 124 | lib32: { |
| 125 | symlinks: ["linker_asan"], |
| 126 | }, |
| 127 | lib64: { |
| 128 | suffix: "64", |
| 129 | symlinks: ["linker_asan64"], |
| 130 | }, |
| 131 | }, |
| 132 | target: { |
| 133 | android64: { |
| 134 | cflags: ["-DTARGET_IS_64_BIT"], |
| 135 | }, |
| 136 | }, |
| 137 | compile_multilib: "both", |
| 138 | |
| 139 | // Leave the symbols in the shared library so that stack unwinders can produce |
| 140 | // meaningful name resolution. |
| 141 | strip: { |
| 142 | keep_symbols: true, |
| 143 | }, |
| 144 | |
| 145 | // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb |
| 146 | // looking up symbols in the linker by mistake. |
| 147 | prefix_symbols: "__dl_", |
| 148 | } |