blob: abd67932a2dfefda28711f131c12232b6666f52b [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",
Colin Cross97f0aef2016-07-14 16:05:46 -070021 "linker_gdb_support.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -070022 "linker_globals.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070023 "linker_libc_support.c",
Dimitry Ivanov3f660572016-09-09 10:00:39 -070024 "linker_main.cpp",
Dimitry Ivanovb943f302016-08-03 16:00:10 -070025 "linker_namespaces.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070026 "linker_logger.cpp",
27 "linker_mapped_file_fragment.cpp",
28 "linker_phdr.cpp",
29 "linker_sdk_versions.cpp",
Dimitry Ivanov48ec2882016-08-04 11:50:36 -070030 "linker_soinfo.cpp",
Colin Cross97f0aef2016-07-14 16:05:46 -070031 "linker_utils.cpp",
32 "rt.cpp",
33 ],
34
35 arch: {
36 arm: {
37 srcs: ["arch/arm/begin.S"],
38
39 cflags: ["-D__work_around_b_24465209__"],
40 },
41 arm64: {
42 srcs: ["arch/arm64/begin.S"],
43 },
44 x86: {
45 srcs: ["arch/x86/begin.c"],
46
47 cflags: ["-D__work_around_b_24465209__"],
48 },
49 x86_64: {
50 srcs: ["arch/x86_64/begin.S"],
51 },
52 mips: {
53 srcs: [
54 "arch/mips/begin.S",
55 "linker_mips.cpp",
56 ],
57 },
58 mips64: {
59 srcs: [
60 "arch/mips64/begin.S",
61 "linker_mips.cpp",
62 ],
63 },
64 },
65
66 // We need to access Bionic private headers in the linker.
67 include_dirs: ["bionic/libc"],
68
69 // -shared is used to overwrite the -Bstatic and -static
70 // flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
71 // This dynamic linker is actually a shared object linked with static libraries.
72 ldflags: [
73 "-shared",
74 "-Wl,-Bsymbolic",
75 "-Wl,--exclude-libs,ALL",
76 ],
77
78 cflags: [
79 "-fno-stack-protector",
80 "-Wstrict-overflow=5",
81 "-fvisibility=hidden",
82 "-Wall",
83 "-Wextra",
84 "-Wunused",
85 "-Werror",
86 ],
87
88 // TODO: split out the asflags.
89 asflags: [
90 "-fno-stack-protector",
91 "-Wstrict-overflow=5",
92 "-fvisibility=hidden",
93 "-Wall",
94 "-Wextra",
95 "-Wunused",
96 "-Werror",
97 ],
98
Colin Cross97f0aef2016-07-14 16:05:46 -070099 cppflags: ["-Wold-style-cast"],
100
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800101 // we are going to link libc++_static manually because
102 // when stl is not set to "none" build system adds libdl
103 // to the list of static libraries which needs to be
104 // avoided in the case of building loader.
105 stl: "none",
106
Colin Cross97f0aef2016-07-14 16:05:46 -0700107 // we don't want crtbegin.o (because we have begin.o), so unset it
108 // just for this module
109 nocrt: true,
110
111 static_libs: [
112 "libc_nomalloc",
113 "libziparchive",
114 "libutils",
115 "libbase",
116 "libz",
117 "liblog",
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -0800118 "libc++_static",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700119 "libdebuggerd_handler",
Colin Cross97f0aef2016-07-14 16:05:46 -0700120
121 // Important: The liblinker_malloc should be the last library in the list
122 // to overwrite any other malloc implementations by other static libraries.
123 "liblinker_malloc"
124 ],
125 static_executable: true,
126
127 name: "linker",
Colin Cross10fffb42016-12-08 09:57:35 -0800128 symlinks: ["linker_asan"],
Colin Cross97f0aef2016-07-14 16:05:46 -0700129 multilib: {
Colin Cross97f0aef2016-07-14 16:05:46 -0700130 lib64: {
131 suffix: "64",
Colin Cross10fffb42016-12-08 09:57:35 -0800132 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700133 },
134 target: {
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800135 android: {
136 static_libs: ["libdebuggerd_client"],
137 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700138 android64: {
139 cflags: ["-DTARGET_IS_64_BIT"],
140 },
Dan Willemsen7ec52b12016-11-28 17:02:25 -0800141 linux_bionic: {
142 cflags: ["-DTARGET_IS_64_BIT"],
143 },
Colin Cross97f0aef2016-07-14 16:05:46 -0700144 },
145 compile_multilib: "both",
146
147 // Leave the symbols in the shared library so that stack unwinders can produce
148 // meaningful name resolution.
149 strip: {
150 keep_symbols: true,
151 },
152
153 // Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
154 // looking up symbols in the linker by mistake.
155 prefix_symbols: "__dl_",
156}