blob: a43f8b3f349a224e0e2488a0421cf6e818199ca7 [file] [log] [blame]
Colin Cross97f0aef2016-07-14 16:05:46 -07001cc_library_static {
2 name: "liblinker_malloc",
Dan Willemsen7ec52b12016-11-28 17:02:25 -08003 defaults: ["linux_bionic_supported"],
Colin Cross97f0aef2016-07-14 16:05:46 -07004
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 {
Dan Willemsen7ec52b12016-11-28 17:02:25 -080015 defaults: ["linux_bionic_supported"],
Colin Cross97f0aef2016-07-14 16:05:46 -070016 srcs: [
17 "dlfcn.cpp",
18 "linker.cpp",
19 "linker_block_allocator.cpp",
Dimitry Ivanov769b33f2016-07-21 11:33:40 -070020 "linker_dlwarning.cpp",
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -070021 "linker_cfi.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 Ivanov451909d2017-01-26 16:52:59 -080025 "linker_libcxx_support.cpp",
Dimitry Ivanov3f660572016-09-09 10:00:39 -070026 "linker_main.cpp",
Dimitry Ivanovb943f302016-08-03 16:00:10 -070027 "linker_namespaces.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070028 "linker_logger.cpp",
29 "linker_mapped_file_fragment.cpp",
30 "linker_phdr.cpp",
31 "linker_sdk_versions.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -070032 "linker_soinfo.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070033 "linker_utils.cpp",
34 "rt.cpp",
35 ],
36
37 arch: {
38 arm: {
39 srcs: ["arch/arm/begin.S"],
40
41 cflags: ["-D__work_around_b_24465209__"],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080042 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker"],
Colin Cross97f0aef2016-07-14 16:05:46 -070043 },
44 arm64: {
45 srcs: ["arch/arm64/begin.S"],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080046 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker64"],
Colin Cross97f0aef2016-07-14 16:05:46 -070047 },
48 x86: {
49 srcs: ["arch/x86/begin.c"],
50
51 cflags: ["-D__work_around_b_24465209__"],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080052 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker"],
Colin Cross97f0aef2016-07-14 16:05:46 -070053 },
54 x86_64: {
55 srcs: ["arch/x86_64/begin.S"],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080056 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker64"],
Colin Cross97f0aef2016-07-14 16:05:46 -070057 },
58 mips: {
59 srcs: [
60 "arch/mips/begin.S",
61 "linker_mips.cpp",
62 ],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080063 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker"],
Colin Cross97f0aef2016-07-14 16:05:46 -070064 },
65 mips64: {
66 srcs: [
67 "arch/mips64/begin.S",
68 "linker_mips.cpp",
69 ],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080070 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker64"],
Colin Cross97f0aef2016-07-14 16:05:46 -070071 },
72 },
73
74 // We need to access Bionic private headers in the linker.
75 include_dirs: ["bionic/libc"],
76
77 // -shared is used to overwrite the -Bstatic and -static
78 // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
79 // This dynamic linker is actually a shared object linked with static libraries.
80 ldflags: [
81 "-shared",
82 "-Wl,-Bsymbolic",
83 "-Wl,--exclude-libs,ALL",
84 ],
85
86 cflags: [
87 "-fno-stack-protector",
88 "-Wstrict-overflow=5",
89 "-fvisibility=hidden",
90 "-Wall",
91 "-Wextra",
92 "-Wunused",
93 "-Werror",
94 ],
95
96 // TODO: split out the asflags.
97 asflags: [
98 "-fno-stack-protector",
99 "-Wstrict-overflow=5",
100 "-fvisibility=hidden",
101 "-Wall",
102 "-Wextra",
103 "-Wunused",
104 "-Werror",
105 ],
106
Colin Cross97f0aef2016-07-14 16:05:46 -0700107 cppflags: ["-Wold-style-cast"],
108
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800109 // we are going to link libc++_static manually because
110 // when stl is not set to "none" build system adds libdl
111 // to the list of static libraries which needs to be
112 // avoided in the case of building loader.
113 stl: "none",
114
Colin Cross97f0aef2016-07-14 16:05:46 -0700115 // we don't want crtbegin.o (because we have begin.o), so unset it
116 // just for this module
117 nocrt: true,
118
119 static_libs: [
120 "libc_nomalloc",
Dimitry Ivanov451909d2017-01-26 16:52:59 -0800121 "libm",
Colin Cross97f0aef2016-07-14 16:05:46 -0700122 "libziparchive",
123 "libutils",
124 "libbase",
125 "libz",
Josh Gaoec0dbc32017-02-08 17:27:20 -0800126
127 "libdebuggerd_handler_core",
128 "libdebuggerd_handler_fallback",
129 "libdebuggerd",
130 "libbacktrace",
131 "libunwind",
132 "liblzma",
133 "libcutils",
134
Colin Cross97f0aef2016-07-14 16:05:46 -0700135 "liblog",
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800136 "libc++_static",
Colin Cross97f0aef2016-07-14 16:05:46 -0700137
138 // Important: The liblinker_malloc should be the last library in the list
139 // to overwrite any other malloc implementations by other static libraries.
140 "liblinker_malloc"
141 ],
142 static_executable: true,
143
144 name: "linker",
Colin Cross10fffb42016-12-08 09:57:35 -0800145 symlinks: ["linker_asan"],
Colin Cross97f0aef2016-07-14 16:05:46 -0700146 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700147 lib64: {
148 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800149 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700150 },
151 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800152 android: {
153 static_libs: ["libdebuggerd_client"],
154 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700155 android64: {
156 cflags: ["-DTARGET_IS_64_BIT"],
157 },
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800158 linux_bionic: {
159 cflags: ["-DTARGET_IS_64_BIT"],
160 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700161 },
162 compile_multilib: "both",
163
164 // Leave the symbols in the shared library so that stack unwinders can produce
165 // meaningful name resolution.
166 strip: {
167 keep_symbols: true,
168 },
169
170 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
171 // looking up symbols in the linker by mistake.
172 prefix_symbols: "__dl_",
173}