blob: d6171890efd5cb46606deddd0dd33f747f5c0c1f [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__"],
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
Colin Cross97f0aef2016-07-14 16:05:46 -0700102 cppflags: ["-Wold-style-cast"],
103
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800104 // we are going to link libc++_static manually because
105 // when stl is not set to "none" build system adds libdl
106 // to the list of static libraries which needs to be
107 // avoided in the case of building loader.
108 stl: "none",
109
Colin Cross97f0aef2016-07-14 16:05:46 -0700110 // we don't want crtbegin.o (because we have begin.o), so unset it
111 // just for this module
112 nocrt: true,
113
114 static_libs: [
115 "libc_nomalloc",
Dimitry Ivanov451909d2017-01-26 16:52:59 -0800116 "libm",
Colin Cross97f0aef2016-07-14 16:05:46 -0700117 "libziparchive",
118 "libutils",
119 "libbase",
120 "libz",
Josh Gaoec0dbc32017-02-08 17:27:20 -0800121
Josh Gaoec0dbc32017-02-08 17:27:20 -0800122 "libdebuggerd_handler_fallback",
Josh Gaoec0dbc32017-02-08 17:27:20 -0800123
Colin Cross97f0aef2016-07-14 16:05:46 -0700124 "liblog",
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800125 "libc++_static",
Colin Cross97f0aef2016-07-14 16:05:46 -0700126
127 // Important: The liblinker_malloc should be the last library in the list
128 // to overwrite any other malloc implementations by other static libraries.
129 "liblinker_malloc"
130 ],
131 static_executable: true,
132
133 name: "linker",
Colin Cross10fffb42016-12-08 09:57:35 -0800134 symlinks: ["linker_asan"],
Colin Cross97f0aef2016-07-14 16:05:46 -0700135 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700136 lib64: {
137 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800138 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700139 },
140 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800141 android: {
142 static_libs: ["libdebuggerd_client"],
143 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700144 android64: {
145 cflags: ["-DTARGET_IS_64_BIT"],
146 },
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800147 linux_bionic: {
148 cflags: ["-DTARGET_IS_64_BIT"],
149 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700150 },
151 compile_multilib: "both",
152
153 // Leave the symbols in the shared library so that stack unwinders can produce
154 // meaningful name resolution.
155 strip: {
156 keep_symbols: true,
157 },
158
159 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
160 // looking up symbols in the linker by mistake.
161 prefix_symbols: "__dl_",
162}