blob: aab05b4ee8bebae0c47dd3ada97943fa4df67b30 [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__"],
42 },
43 arm64: {
44 srcs: ["arch/arm64/begin.S"],
45 },
46 x86: {
47 srcs: ["arch/x86/begin.c"],
48
49 cflags: ["-D__work_around_b_24465209__"],
50 },
51 x86_64: {
52 srcs: ["arch/x86_64/begin.S"],
53 },
54 mips: {
55 srcs: [
56 "arch/mips/begin.S",
57 "linker_mips.cpp",
58 ],
59 },
60 mips64: {
61 srcs: [
62 "arch/mips64/begin.S",
63 "linker_mips.cpp",
64 ],
65 },
66 },
67
68 // We need to access Bionic private headers in the linker.
69 include_dirs: ["bionic/libc"],
70
71 // -shared is used to overwrite the -Bstatic and -static
72 // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
73 // This dynamic linker is actually a shared object linked with static libraries.
74 ldflags: [
75 "-shared",
76 "-Wl,-Bsymbolic",
77 "-Wl,--exclude-libs,ALL",
78 ],
79
80 cflags: [
81 "-fno-stack-protector",
82 "-Wstrict-overflow=5",
83 "-fvisibility=hidden",
84 "-Wall",
85 "-Wextra",
86 "-Wunused",
87 "-Werror",
88 ],
89
90 // TODO: split out the asflags.
91 asflags: [
92 "-fno-stack-protector",
93 "-Wstrict-overflow=5",
94 "-fvisibility=hidden",
95 "-Wall",
96 "-Wextra",
97 "-Wunused",
98 "-Werror",
99 ],
100
Colin Cross97f0aef2016-07-14 16:05:46 -0700101 cppflags: ["-Wold-style-cast"],
102
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800103 // we are going to link libc++_static manually because
104 // when stl is not set to "none" build system adds libdl
105 // to the list of static libraries which needs to be
106 // avoided in the case of building loader.
107 stl: "none",
108
Colin Cross97f0aef2016-07-14 16:05:46 -0700109 // we don't want crtbegin.o (because we have begin.o), so unset it
110 // just for this module
111 nocrt: true,
112
113 static_libs: [
114 "libc_nomalloc",
Dimitry Ivanov451909d2017-01-26 16:52:59 -0800115 "libm",
Colin Cross97f0aef2016-07-14 16:05:46 -0700116 "libziparchive",
117 "libutils",
118 "libbase",
119 "libz",
Josh Gaoec0dbc32017-02-08 17:27:20 -0800120
121 "libdebuggerd_handler_core",
122 "libdebuggerd_handler_fallback",
123 "libdebuggerd",
124 "libbacktrace",
125 "libunwind",
126 "liblzma",
127 "libcutils",
128
Colin Cross97f0aef2016-07-14 16:05:46 -0700129 "liblog",
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800130 "libc++_static",
Colin Cross97f0aef2016-07-14 16:05:46 -0700131
132 // Important: The liblinker_malloc should be the last library in the list
133 // to overwrite any other malloc implementations by other static libraries.
134 "liblinker_malloc"
135 ],
136 static_executable: true,
137
138 name: "linker",
Colin Cross10fffb42016-12-08 09:57:35 -0800139 symlinks: ["linker_asan"],
Colin Cross97f0aef2016-07-14 16:05:46 -0700140 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700141 lib64: {
142 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800143 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700144 },
145 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800146 android: {
147 static_libs: ["libdebuggerd_client"],
148 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700149 android64: {
150 cflags: ["-DTARGET_IS_64_BIT"],
151 },
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800152 linux_bionic: {
153 cflags: ["-DTARGET_IS_64_BIT"],
154 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700155 },
156 compile_multilib: "both",
157
158 // Leave the symbols in the shared library so that stack unwinders can produce
159 // meaningful name resolution.
160 strip: {
161 keep_symbols: true,
162 },
163
164 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
165 // looking up symbols in the linker by mistake.
166 prefix_symbols: "__dl_",
167}