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