blob: 2351e71ca3044c0723bf2dc6c5c2f09276ad1a17 [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",
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -080022 "linker_config.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070023 "linker_gdb_support.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -070024 "linker_globals.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070025 "linker_libc_support.c",
Dimitry Ivanov451909d2017-01-26 16:52:59 -080026 "linker_libcxx_support.cpp",
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__"],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080043 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker"],
Colin Cross97f0aef2016-07-14 16:05:46 -070044 },
45 arm64: {
46 srcs: ["arch/arm64/begin.S"],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080047 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker64"],
Colin Cross97f0aef2016-07-14 16:05:46 -070048 },
49 x86: {
50 srcs: ["arch/x86/begin.c"],
51
52 cflags: ["-D__work_around_b_24465209__"],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080053 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker"],
Colin Cross97f0aef2016-07-14 16:05:46 -070054 },
55 x86_64: {
56 srcs: ["arch/x86_64/begin.S"],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080057 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker64"],
Colin Cross97f0aef2016-07-14 16:05:46 -070058 },
59 mips: {
60 srcs: [
61 "arch/mips/begin.S",
62 "linker_mips.cpp",
63 ],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080064 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker"],
Colin Cross97f0aef2016-07-14 16:05:46 -070065 },
66 mips64: {
67 srcs: [
68 "arch/mips64/begin.S",
69 "linker_mips.cpp",
70 ],
Dimitry Ivanov2a6955e2017-02-23 11:53:43 -080071 ldflags: ["-Wl,-dynamic-linker,/system/bin/linker64"],
Colin Cross97f0aef2016-07-14 16:05:46 -070072 },
73 },
74
75 // We need to access Bionic private headers in the linker.
76 include_dirs: ["bionic/libc"],
77
78 // -shared is used to overwrite the -Bstatic and -static
79 // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
80 // This dynamic linker is actually a shared object linked with static libraries.
81 ldflags: [
82 "-shared",
83 "-Wl,-Bsymbolic",
84 "-Wl,--exclude-libs,ALL",
85 ],
86
87 cflags: [
88 "-fno-stack-protector",
89 "-Wstrict-overflow=5",
90 "-fvisibility=hidden",
91 "-Wall",
92 "-Wextra",
93 "-Wunused",
94 "-Werror",
95 ],
96
97 // TODO: split out the asflags.
98 asflags: [
99 "-fno-stack-protector",
100 "-Wstrict-overflow=5",
101 "-fvisibility=hidden",
102 "-Wall",
103 "-Wextra",
104 "-Wunused",
105 "-Werror",
106 ],
107
Colin Cross97f0aef2016-07-14 16:05:46 -0700108 cppflags: ["-Wold-style-cast"],
109
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800110 // we are going to link libc++_static manually because
111 // when stl is not set to "none" build system adds libdl
112 // to the list of static libraries which needs to be
113 // avoided in the case of building loader.
114 stl: "none",
115
Colin Cross97f0aef2016-07-14 16:05:46 -0700116 // we don't want crtbegin.o (because we have begin.o), so unset it
117 // just for this module
118 nocrt: true,
119
120 static_libs: [
121 "libc_nomalloc",
Dimitry Ivanov451909d2017-01-26 16:52:59 -0800122 "libm",
Colin Cross97f0aef2016-07-14 16:05:46 -0700123 "libziparchive",
124 "libutils",
125 "libbase",
126 "libz",
Josh Gaoec0dbc32017-02-08 17:27:20 -0800127
128 "libdebuggerd_handler_core",
129 "libdebuggerd_handler_fallback",
130 "libdebuggerd",
131 "libbacktrace",
132 "libunwind",
133 "liblzma",
134 "libcutils",
135
Colin Cross97f0aef2016-07-14 16:05:46 -0700136 "liblog",
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800137 "libc++_static",
Colin Cross97f0aef2016-07-14 16:05:46 -0700138
139 // Important: The liblinker_malloc should be the last library in the list
140 // to overwrite any other malloc implementations by other static libraries.
141 "liblinker_malloc"
142 ],
143 static_executable: true,
144
145 name: "linker",
Colin Cross10fffb42016-12-08 09:57:35 -0800146 symlinks: ["linker_asan"],
Colin Cross97f0aef2016-07-14 16:05:46 -0700147 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700148 lib64: {
149 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800150 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700151 },
152 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800153 android: {
154 static_libs: ["libdebuggerd_client"],
155 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700156 android64: {
157 cflags: ["-DTARGET_IS_64_BIT"],
158 },
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800159 linux_bionic: {
160 cflags: ["-DTARGET_IS_64_BIT"],
161 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700162 },
163 compile_multilib: "both",
164
165 // Leave the symbols in the shared library so that stack unwinders can produce
166 // meaningful name resolution.
167 strip: {
168 keep_symbols: true,
169 },
170
171 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
172 // looking up symbols in the linker by mistake.
173 prefix_symbols: "__dl_",
174}