blob: f96e038bec26e63bb9d98069bfd4416a9886eff9 [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"],
Christopher Ferris7a3681e2017-04-24 17:48:32 -070012
13 static_libs: ["libasync_safe"],
Colin Cross97f0aef2016-07-14 16:05:46 -070014}
15
16cc_binary {
Dan Willemsen7ec52b12016-11-28 17:02:25 -080017 defaults: ["linux_bionic_supported"],
Colin Cross97f0aef2016-07-14 16:05:46 -070018 srcs: [
19 "dlfcn.cpp",
20 "linker.cpp",
21 "linker_block_allocator.cpp",
Dimitry Ivanov769b33f2016-07-21 11:33:40 -070022 "linker_dlwarning.cpp",
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -070023 "linker_cfi.cpp",
Dimitry Ivanov4cabfaa2017-03-07 11:19:05 -080024 "linker_config.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070025 "linker_gdb_support.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -070026 "linker_globals.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070027 "linker_libc_support.c",
Dimitry Ivanov451909d2017-01-26 16:52:59 -080028 "linker_libcxx_support.cpp",
Dimitry Ivanov3f660572016-09-09 10:00:39 -070029 "linker_main.cpp",
Dimitry Ivanovb943f302016-08-03 16:00:10 -070030 "linker_namespaces.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070031 "linker_logger.cpp",
32 "linker_mapped_file_fragment.cpp",
33 "linker_phdr.cpp",
34 "linker_sdk_versions.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -070035 "linker_soinfo.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070036 "linker_utils.cpp",
37 "rt.cpp",
38 ],
39
40 arch: {
41 arm: {
dimitry25bf29b2017-08-29 13:38:04 +020042 srcs: [
43 "arch/arm/begin.S",
44 "linker_exidx_static.c",
45 ],
Colin Cross97f0aef2016-07-14 16:05:46 -070046
47 cflags: ["-D__work_around_b_24465209__"],
dimitry7abea572017-08-29 18:14:49 +020048 version_script: "linker.arm.map",
Colin Cross97f0aef2016-07-14 16:05:46 -070049 },
50 arm64: {
51 srcs: ["arch/arm64/begin.S"],
dimitry7abea572017-08-29 18:14:49 +020052 version_script: "linker.generic.map",
Colin Cross97f0aef2016-07-14 16:05:46 -070053 },
54 x86: {
55 srcs: ["arch/x86/begin.c"],
56
57 cflags: ["-D__work_around_b_24465209__"],
dimitry7abea572017-08-29 18:14:49 +020058 version_script: "linker.generic.map",
Colin Cross97f0aef2016-07-14 16:05:46 -070059 },
60 x86_64: {
61 srcs: ["arch/x86_64/begin.S"],
dimitry7abea572017-08-29 18:14:49 +020062 version_script: "linker.generic.map",
Colin Cross97f0aef2016-07-14 16:05:46 -070063 },
64 mips: {
65 srcs: [
66 "arch/mips/begin.S",
67 "linker_mips.cpp",
68 ],
dimitry7abea572017-08-29 18:14:49 +020069 version_script: "linker.generic.map",
Colin Cross97f0aef2016-07-14 16:05:46 -070070 },
71 mips64: {
72 srcs: [
73 "arch/mips64/begin.S",
74 "linker_mips.cpp",
75 ],
dimitry7abea572017-08-29 18:14:49 +020076 version_script: "linker.generic.map",
Colin Cross97f0aef2016-07-14 16:05:46 -070077 },
78 },
79
80 // We need to access Bionic private headers in the linker.
81 include_dirs: ["bionic/libc"],
82
83 // -shared is used to overwrite the -Bstatic and -static
84 // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
85 // This dynamic linker is actually a shared object linked with static libraries.
86 ldflags: [
87 "-shared",
88 "-Wl,-Bsymbolic",
89 "-Wl,--exclude-libs,ALL",
90 ],
91
92 cflags: [
93 "-fno-stack-protector",
94 "-Wstrict-overflow=5",
95 "-fvisibility=hidden",
96 "-Wall",
97 "-Wextra",
98 "-Wunused",
99 "-Werror",
100 ],
101
102 // TODO: split out the asflags.
103 asflags: [
104 "-fno-stack-protector",
105 "-Wstrict-overflow=5",
106 "-fvisibility=hidden",
107 "-Wall",
108 "-Wextra",
109 "-Wunused",
110 "-Werror",
111 ],
112
Jiyong Park02586a22017-05-20 01:01:24 +0900113 product_variables: {
114 debuggable: {
115 cppflags: ["-DUSE_LD_CONFIG_FILE"],
116 },
117 },
118
Colin Cross97f0aef2016-07-14 16:05:46 -0700119 cppflags: ["-Wold-style-cast"],
120
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800121 // we are going to link libc++_static manually because
122 // when stl is not set to "none" build system adds libdl
123 // to the list of static libraries which needs to be
124 // avoided in the case of building loader.
125 stl: "none",
126
Colin Cross97f0aef2016-07-14 16:05:46 -0700127 // we don't want crtbegin.o (because we have begin.o), so unset it
128 // just for this module
129 nocrt: true,
130
131 static_libs: [
132 "libc_nomalloc",
Dimitry Ivanov451909d2017-01-26 16:52:59 -0800133 "libm",
Colin Cross97f0aef2016-07-14 16:05:46 -0700134 "libziparchive",
135 "libutils",
136 "libbase",
137 "libz",
Josh Gaoec0dbc32017-02-08 17:27:20 -0800138
Josh Gaoec0dbc32017-02-08 17:27:20 -0800139 "libdebuggerd_handler_fallback",
Josh Gaoec0dbc32017-02-08 17:27:20 -0800140
Colin Cross97f0aef2016-07-14 16:05:46 -0700141 "liblog",
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800142 "libc++_static",
Colin Cross97f0aef2016-07-14 16:05:46 -0700143
144 // Important: The liblinker_malloc should be the last library in the list
145 // to overwrite any other malloc implementations by other static libraries.
146 "liblinker_malloc"
147 ],
148 static_executable: true,
149
150 name: "linker",
Colin Cross10fffb42016-12-08 09:57:35 -0800151 symlinks: ["linker_asan"],
Colin Cross97f0aef2016-07-14 16:05:46 -0700152 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700153 lib64: {
154 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800155 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700156 },
157 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800158 android: {
159 static_libs: ["libdebuggerd_client"],
160 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700161 android64: {
162 cflags: ["-DTARGET_IS_64_BIT"],
163 },
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800164 linux_bionic: {
165 cflags: ["-DTARGET_IS_64_BIT"],
166 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700167 },
168 compile_multilib: "both",
169
170 // Leave the symbols in the shared library so that stack unwinders can produce
171 // meaningful name resolution.
172 strip: {
173 keep_symbols: true,
174 },
175
176 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
177 // looking up symbols in the linker by mistake.
178 prefix_symbols: "__dl_",
179}