blob: 239e54b04678070ca69f82982874aab13e20a332 [file] [log] [blame]
Colin Cross97f0aef2016-07-14 16:05:46 -07001cc_library_static {
2 name: "liblinker_malloc",
Andreas Gampedcb846c2016-12-06 02:10:13 +00003 clang: true,
Dan Willemsen7ec52b12016-11-28 17:02:25 -08004 defaults: ["linux_bionic_supported"],
Colin Cross97f0aef2016-07-14 16:05:46 -07005
6 srcs: [
7 "linker_allocator.cpp",
8 "linker_memory.cpp",
9 ],
10
11 // We need to access Bionic private headers in the linker.
12 include_dirs: ["bionic/libc"],
13}
14
15cc_binary {
Andreas Gampedcb846c2016-12-06 02:10:13 +000016 clang: true,
Dan Willemsen7ec52b12016-11-28 17:02:25 -080017 defaults: ["linux_bionic_supported"],
Andreas Gampedcb846c2016-12-06 02:10:13 +000018
Colin Cross97f0aef2016-07-14 16:05:46 -070019 srcs: [
20 "dlfcn.cpp",
21 "linker.cpp",
22 "linker_block_allocator.cpp",
Dimitry Ivanov769b33f2016-07-21 11:33:40 -070023 "linker_dlwarning.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070024 "linker_gdb_support.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -070025 "linker_globals.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070026 "linker_libc_support.c",
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__"],
43 },
44 arm64: {
45 srcs: ["arch/arm64/begin.S"],
46 },
47 x86: {
48 srcs: ["arch/x86/begin.c"],
49
50 cflags: ["-D__work_around_b_24465209__"],
51 },
52 x86_64: {
53 srcs: ["arch/x86_64/begin.S"],
54 },
55 mips: {
56 srcs: [
57 "arch/mips/begin.S",
58 "linker_mips.cpp",
59 ],
60 },
61 mips64: {
62 srcs: [
63 "arch/mips64/begin.S",
64 "linker_mips.cpp",
65 ],
66 },
67 },
68
69 // We need to access Bionic private headers in the linker.
70 include_dirs: ["bionic/libc"],
71
72 // -shared is used to overwrite the -Bstatic and -static
73 // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
74 // This dynamic linker is actually a shared object linked with static libraries.
75 ldflags: [
76 "-shared",
77 "-Wl,-Bsymbolic",
78 "-Wl,--exclude-libs,ALL",
79 ],
80
81 cflags: [
82 "-fno-stack-protector",
83 "-Wstrict-overflow=5",
84 "-fvisibility=hidden",
85 "-Wall",
86 "-Wextra",
87 "-Wunused",
88 "-Werror",
89 ],
90
91 // TODO: split out the asflags.
92 asflags: [
93 "-fno-stack-protector",
94 "-Wstrict-overflow=5",
95 "-fvisibility=hidden",
96 "-Wall",
97 "-Wextra",
98 "-Wunused",
99 "-Werror",
100 ],
101
Andreas Gampedcb846c2016-12-06 02:10:13 +0000102 conlyflags: ["-std=gnu99"],
103
Colin Cross97f0aef2016-07-14 16:05:46 -0700104 cppflags: ["-Wold-style-cast"],
105
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800106 // we are going to link libc++_static manually because
107 // when stl is not set to "none" build system adds libdl
108 // to the list of static libraries which needs to be
109 // avoided in the case of building loader.
110 stl: "none",
111
Colin Cross97f0aef2016-07-14 16:05:46 -0700112 // we don't want crtbegin.o (because we have begin.o), so unset it
113 // just for this module
114 nocrt: true,
115
116 static_libs: [
117 "libc_nomalloc",
118 "libziparchive",
119 "libutils",
120 "libbase",
121 "libz",
122 "liblog",
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800123 "libc++_static",
Colin Cross97f0aef2016-07-14 16:05:46 -0700124
125 // Important: The liblinker_malloc should be the last library in the list
126 // to overwrite any other malloc implementations by other static libraries.
127 "liblinker_malloc"
128 ],
129 static_executable: true,
130
131 name: "linker",
Colin Cross10fffb42016-12-08 09:57:35 -0800132 symlinks: ["linker_asan"],
Colin Cross97f0aef2016-07-14 16:05:46 -0700133 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700134 lib64: {
135 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800136 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700137 },
138 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800139 android: {
140 static_libs: ["libdebuggerd_client"],
141 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700142 android64: {
143 cflags: ["-DTARGET_IS_64_BIT"],
144 },
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800145 linux_bionic: {
146 cflags: ["-DTARGET_IS_64_BIT"],
147 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700148 },
149 compile_multilib: "both",
150
151 // Leave the symbols in the shared library so that stack unwinders can produce
152 // meaningful name resolution.
153 strip: {
154 keep_symbols: true,
155 },
156
157 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
158 // looking up symbols in the linker by mistake.
159 prefix_symbols: "__dl_",
160}