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