blob: 5c205d5ab618ce8d4ee65eec8c09d3139b7fe218 [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",
120 "liblog",
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800121 "libc++_static",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700122 "libdebuggerd_handler",
Colin Cross97f0aef2016-07-14 16:05:46 -0700123
124 // Important: The liblinker_malloc should be the last library in the list
125 // to overwrite any other malloc implementations by other static libraries.
126 "liblinker_malloc"
127 ],
128 static_executable: true,
129
130 name: "linker",
Colin Cross10fffb42016-12-08 09:57:35 -0800131 symlinks: ["linker_asan"],
Colin Cross97f0aef2016-07-14 16:05:46 -0700132 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700133 lib64: {
134 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800135 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700136 },
137 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800138 android: {
139 static_libs: ["libdebuggerd_client"],
140 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700141 android64: {
142 cflags: ["-DTARGET_IS_64_BIT"],
143 },
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800144 linux_bionic: {
145 cflags: ["-DTARGET_IS_64_BIT"],
146 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700147 },
148 compile_multilib: "both",
149
150 // Leave the symbols in the shared library so that stack unwinders can produce
151 // meaningful name resolution.
152 strip: {
153 keep_symbols: true,
154 },
155
156 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
157 // looking up symbols in the linker by mistake.
158 prefix_symbols: "__dl_",
159}