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