blob: 5745d73269b00f986e269b38856f953211b25bd4 [file] [log] [blame]
Colin Cross97f0aef2016-07-14 16:05:46 -07001cc_library_static {
2 name: "liblinker_malloc",
Andreas Gampedcb846c2016-12-06 02:10:13 +00003 clang: true,
Dan Willemsen7ec52b12016-11-28 17:02:25 -08004 defaults: ["linux_bionic_supported"],
Colin Cross97f0aef2016-07-14 16:05:46 -07005
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
15cc_binary {
Andreas Gampedcb846c2016-12-06 02:10:13 +000016 clang: true,
Dan Willemsen7ec52b12016-11-28 17:02:25 -080017 defaults: ["linux_bionic_supported"],
Andreas Gampedcb846c2016-12-06 02:10:13 +000018
Colin Cross97f0aef2016-07-14 16:05:46 -070019 srcs: [
20 "dlfcn.cpp",
21 "linker.cpp",
22 "linker_block_allocator.cpp",
Dimitry Ivanov769b33f2016-07-21 11:33:40 -070023 "linker_dlwarning.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070024 "linker_gdb_support.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -070025 "linker_globals.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070026 "linker_libc_support.c",
Dimitry Ivanov3f660572016-09-09 10:00:39 -070027 "linker_main.cpp",
Dimitry Ivanovb943f302016-08-03 16:00:10 -070028 "linker_namespaces.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070029 "linker_logger.cpp",
30 "linker_mapped_file_fragment.cpp",
31 "linker_phdr.cpp",
32 "linker_sdk_versions.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -070033 "linker_soinfo.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070034 "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 Gampedcb846c2016-12-06 02:10:13 +0000102 conlyflags: ["-std=gnu99"],
103
Colin Cross97f0aef2016-07-14 16:05:46 -0700104 cppflags: ["-Wold-style-cast"],
105
106 // we don't want crtbegin.o (because we have begin.o), so unset it
107 // just for this module
108 nocrt: true,
109
110 static_libs: [
111 "libc_nomalloc",
112 "libziparchive",
113 "libutils",
114 "libbase",
115 "libz",
116 "liblog",
Colin Cross97f0aef2016-07-14 16:05:46 -0700117
118 // Important: The liblinker_malloc should be the last library in the list
119 // to overwrite any other malloc implementations by other static libraries.
120 "liblinker_malloc"
121 ],
122 static_executable: true,
123
124 name: "linker",
125 multilib: {
126 lib32: {
127 symlinks: ["linker_asan"],
128 },
129 lib64: {
130 suffix: "64",
131 symlinks: ["linker_asan64"],
132 },
133 },
134 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800135 android: {
136 static_libs: ["libdebuggerd_client"],
137 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700138 android64: {
139 cflags: ["-DTARGET_IS_64_BIT"],
140 },
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800141 linux_bionic: {
142 cflags: ["-DTARGET_IS_64_BIT"],
143 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700144 },
145 compile_multilib: "both",
146
147 // Leave the symbols in the shared library so that stack unwinders can produce
148 // meaningful name resolution.
149 strip: {
150 keep_symbols: true,
151 },
152
153 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
154 // looking up symbols in the linker by mistake.
155 prefix_symbols: "__dl_",
156}