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