2016-07-14 23:05:46 +00:00
|
|
|
cc_library_static {
|
|
|
|
name: "liblinker_malloc",
|
2016-11-29 01:02:25 +00:00
|
|
|
defaults: ["linux_bionic_supported"],
|
2018-05-29 07:34:39 +00:00
|
|
|
recovery_available: true,
|
2016-07-14 23:05:46 +00:00
|
|
|
|
|
|
|
srcs: [
|
|
|
|
"linker_allocator.cpp",
|
|
|
|
"linker_memory.cpp",
|
|
|
|
],
|
2018-02-06 01:30:57 +00:00
|
|
|
cflags: [
|
|
|
|
"-Wall",
|
|
|
|
"-Werror",
|
|
|
|
],
|
2016-07-14 23:05:46 +00:00
|
|
|
|
|
|
|
// We need to access Bionic private headers in the linker.
|
|
|
|
include_dirs: ["bionic/libc"],
|
2017-04-25 00:48:32 +00:00
|
|
|
|
2018-10-25 18:00:00 +00:00
|
|
|
static_libs: ["libasync_safe", "libbase"],
|
2016-07-14 23:05:46 +00:00
|
|
|
}
|
|
|
|
|
2017-09-19 04:28:14 +00:00
|
|
|
// This is used for bionic on (host) Linux to bootstrap our linker embedded into
|
|
|
|
// a binary.
|
|
|
|
//
|
|
|
|
// Host bionic binaries do not have a PT_INTERP section, instead this gets
|
|
|
|
// embedded as the entry point, and the linker is embedded as ELF sections in
|
|
|
|
// each binary. There's a linker script that sets all of that up (generated by
|
|
|
|
// extract_linker), and defines the extern symbols used in this file.
|
|
|
|
cc_object {
|
|
|
|
name: "linker_wrapper",
|
|
|
|
host_supported: true,
|
|
|
|
device_supported: false,
|
|
|
|
target: {
|
2018-02-06 01:30:57 +00:00
|
|
|
linux_bionic: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
linux_glibc: {
|
|
|
|
enabled: false,
|
|
|
|
},
|
|
|
|
darwin: {
|
|
|
|
enabled: false,
|
|
|
|
},
|
2017-09-19 04:28:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
cflags: [
|
|
|
|
"-fno-stack-protector",
|
|
|
|
"-Wstrict-overflow=5",
|
|
|
|
"-fvisibility=hidden",
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wno-unused",
|
|
|
|
"-Werror",
|
|
|
|
],
|
|
|
|
|
|
|
|
srcs: [
|
|
|
|
"linker_wrapper.cpp",
|
|
|
|
],
|
|
|
|
arch: {
|
|
|
|
x86_64: {
|
|
|
|
srcs: ["arch/x86_64/begin.S"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
prefix_symbols: "__dlwrap_",
|
|
|
|
|
|
|
|
// We need to access Bionic private headers in the linker.
|
|
|
|
include_dirs: ["bionic/libc"],
|
|
|
|
}
|
|
|
|
|
2018-09-25 10:31:11 +00:00
|
|
|
filegroup {
|
|
|
|
name: "linker_sources",
|
2016-07-14 23:05:46 +00:00
|
|
|
srcs: [
|
|
|
|
"dlfcn.cpp",
|
|
|
|
"linker.cpp",
|
|
|
|
"linker_block_allocator.cpp",
|
2016-07-21 18:33:40 +00:00
|
|
|
"linker_dlwarning.cpp",
|
2016-07-06 20:20:59 +00:00
|
|
|
"linker_cfi.cpp",
|
2017-03-07 19:19:05 +00:00
|
|
|
"linker_config.cpp",
|
2016-07-14 23:05:46 +00:00
|
|
|
"linker_gdb_support.cpp",
|
2016-08-04 18:50:36 +00:00
|
|
|
"linker_globals.cpp",
|
2016-07-14 23:05:46 +00:00
|
|
|
"linker_libc_support.c",
|
2017-01-27 00:52:59 +00:00
|
|
|
"linker_libcxx_support.cpp",
|
2016-09-09 17:00:39 +00:00
|
|
|
"linker_main.cpp",
|
2016-08-03 23:00:10 +00:00
|
|
|
"linker_namespaces.cpp",
|
2016-07-14 23:05:46 +00:00
|
|
|
"linker_logger.cpp",
|
|
|
|
"linker_mapped_file_fragment.cpp",
|
|
|
|
"linker_phdr.cpp",
|
|
|
|
"linker_sdk_versions.cpp",
|
2016-08-04 18:50:36 +00:00
|
|
|
"linker_soinfo.cpp",
|
2016-07-14 23:05:46 +00:00
|
|
|
"linker_utils.cpp",
|
|
|
|
"rt.cpp",
|
|
|
|
],
|
2018-09-25 10:31:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
filegroup {
|
|
|
|
name: "linker_sources_arm",
|
|
|
|
srcs: [
|
|
|
|
"arch/arm/begin.S",
|
|
|
|
"linker_exidx_static.c",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
filegroup {
|
|
|
|
name: "linker_sources_arm64",
|
|
|
|
srcs: [
|
|
|
|
"arch/arm64/begin.S",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
filegroup {
|
|
|
|
name: "linker_sources_x86",
|
|
|
|
srcs: [
|
|
|
|
"arch/x86/begin.S",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
filegroup {
|
|
|
|
name: "linker_sources_x86_64",
|
|
|
|
srcs: [
|
|
|
|
"arch/x86_64/begin.S",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
filegroup {
|
|
|
|
name: "linker_sources_mips",
|
|
|
|
srcs: [
|
|
|
|
"arch/mips/begin.S",
|
|
|
|
"linker_mips.cpp",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
filegroup {
|
|
|
|
name: "linker_sources_mips64",
|
|
|
|
srcs: [
|
|
|
|
"arch/mips64/begin.S",
|
|
|
|
"linker_mips.cpp",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
filegroup {
|
|
|
|
name: "linker_version_script",
|
|
|
|
srcs: ["linker.generic.map"],
|
|
|
|
}
|
|
|
|
|
|
|
|
filegroup {
|
|
|
|
name: "linker_version_script_arm",
|
|
|
|
srcs: ["linker.arm.map"],
|
|
|
|
}
|
2016-07-14 23:05:46 +00:00
|
|
|
|
2018-09-25 10:31:11 +00:00
|
|
|
cc_defaults {
|
|
|
|
name: "linker_defaults",
|
2016-07-14 23:05:46 +00:00
|
|
|
arch: {
|
|
|
|
arm: {
|
|
|
|
cflags: ["-D__work_around_b_24465209__"],
|
|
|
|
},
|
|
|
|
x86: {
|
2018-05-24 21:07:27 +00:00
|
|
|
cflags: ["-D__work_around_b_24465209__"],
|
2016-07-14 23:05:46 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// -shared is used to overwrite the -Bstatic and -static
|
|
|
|
// flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
|
|
|
|
// This dynamic linker is actually a shared object linked with static libraries.
|
|
|
|
ldflags: [
|
|
|
|
"-shared",
|
|
|
|
"-Wl,-Bsymbolic",
|
|
|
|
"-Wl,--exclude-libs,ALL",
|
2018-01-04 11:08:32 +00:00
|
|
|
"-Wl,-soname,ld-android.so",
|
2016-07-14 23:05:46 +00:00
|
|
|
],
|
|
|
|
|
2018-04-16 16:51:50 +00:00
|
|
|
// lld bug: https://bugs.llvm.org/show_bug.cgi?id=36295
|
|
|
|
// error: symbol __aeabi_*@@LIBC_N has undefined version LIBC_N
|
|
|
|
use_clang_lld: false,
|
|
|
|
|
2016-07-14 23:05:46 +00:00
|
|
|
cflags: [
|
|
|
|
"-fno-stack-protector",
|
|
|
|
"-Wstrict-overflow=5",
|
|
|
|
"-fvisibility=hidden",
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wunused",
|
|
|
|
"-Werror",
|
|
|
|
],
|
|
|
|
|
|
|
|
// TODO: split out the asflags.
|
|
|
|
asflags: [
|
|
|
|
"-fno-stack-protector",
|
|
|
|
"-Wstrict-overflow=5",
|
|
|
|
"-fvisibility=hidden",
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wunused",
|
|
|
|
"-Werror",
|
|
|
|
],
|
|
|
|
|
2017-05-19 16:01:24 +00:00
|
|
|
product_variables: {
|
|
|
|
debuggable: {
|
|
|
|
cppflags: ["-DUSE_LD_CONFIG_FILE"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-07-14 23:05:46 +00:00
|
|
|
cppflags: ["-Wold-style-cast"],
|
|
|
|
|
2016-12-06 19:10:09 +00:00
|
|
|
// we are going to link libc++_static manually because
|
|
|
|
// when stl is not set to "none" build system adds libdl
|
|
|
|
// to the list of static libraries which needs to be
|
|
|
|
// avoided in the case of building loader.
|
|
|
|
stl: "none",
|
|
|
|
|
2016-07-14 23:05:46 +00:00
|
|
|
// we don't want crtbegin.o (because we have begin.o), so unset it
|
|
|
|
// just for this module
|
|
|
|
nocrt: true,
|
|
|
|
|
2018-09-25 10:31:11 +00:00
|
|
|
static_executable: true,
|
|
|
|
|
|
|
|
// Leave the symbols in the shared library so that stack unwinders can produce
|
|
|
|
// meaningful name resolution.
|
|
|
|
strip: {
|
|
|
|
keep_symbols: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
// Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
|
|
|
|
// looking up symbols in the linker by mistake.
|
|
|
|
prefix_symbols: "__dl_",
|
|
|
|
|
|
|
|
sanitize: {
|
|
|
|
hwaddress: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_binary {
|
|
|
|
defaults: ["linux_bionic_supported", "linker_defaults"],
|
|
|
|
srcs: [ ":linker_sources" ],
|
|
|
|
|
|
|
|
arch: {
|
|
|
|
arm: {
|
|
|
|
srcs: [ ":linker_sources_arm" ],
|
|
|
|
version_script: ":linker_version_script_arm",
|
|
|
|
},
|
|
|
|
arm64: {
|
|
|
|
srcs: [":linker_sources_arm64"],
|
|
|
|
version_script: ":linker_version_script",
|
|
|
|
},
|
|
|
|
x86: {
|
|
|
|
srcs: [":linker_sources_x86"],
|
|
|
|
version_script: ":linker_version_script",
|
|
|
|
},
|
|
|
|
x86_64: {
|
|
|
|
srcs: [":linker_sources_x86_64"],
|
|
|
|
version_script: ":linker_version_script",
|
|
|
|
},
|
|
|
|
mips: {
|
|
|
|
srcs: [":linker_sources_mips"],
|
|
|
|
version_script: ":linker_version_script",
|
|
|
|
},
|
|
|
|
mips64: {
|
|
|
|
srcs: [":linker_sources_mips64"],
|
|
|
|
version_script: ":linker_version_script",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// We need to access Bionic private headers in the linker.
|
|
|
|
include_dirs: ["bionic/libc"],
|
|
|
|
|
2016-07-14 23:05:46 +00:00
|
|
|
static_libs: [
|
|
|
|
"libc_nomalloc",
|
2017-01-27 00:52:59 +00:00
|
|
|
"libm",
|
2016-07-14 23:05:46 +00:00
|
|
|
"libziparchive",
|
|
|
|
"libutils",
|
|
|
|
"libbase",
|
|
|
|
"libz",
|
2017-02-09 01:27:20 +00:00
|
|
|
|
2017-05-07 20:07:41 +00:00
|
|
|
"libasync_safe",
|
2017-02-09 01:27:20 +00:00
|
|
|
|
2016-07-14 23:05:46 +00:00
|
|
|
"liblog",
|
2016-12-06 19:10:09 +00:00
|
|
|
"libc++_static",
|
2016-07-14 23:05:46 +00:00
|
|
|
|
|
|
|
// Important: The liblinker_malloc should be the last library in the list
|
|
|
|
// to overwrite any other malloc implementations by other static libraries.
|
2018-02-06 01:30:57 +00:00
|
|
|
"liblinker_malloc",
|
2016-07-14 23:05:46 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
name: "linker",
|
2016-12-08 17:57:35 +00:00
|
|
|
symlinks: ["linker_asan"],
|
2018-05-29 07:34:39 +00:00
|
|
|
recovery_available: true,
|
2016-07-14 23:05:46 +00:00
|
|
|
multilib: {
|
|
|
|
lib64: {
|
|
|
|
suffix: "64",
|
2016-12-08 17:57:35 +00:00
|
|
|
},
|
2016-07-14 23:05:46 +00:00
|
|
|
},
|
|
|
|
target: {
|
2016-11-29 01:02:25 +00:00
|
|
|
android: {
|
2017-05-07 20:07:41 +00:00
|
|
|
static_libs: ["libdebuggerd_handler_fallback"],
|
2016-11-29 01:02:25 +00:00
|
|
|
},
|
2016-07-14 23:05:46 +00:00
|
|
|
},
|
|
|
|
compile_multilib: "both",
|
|
|
|
}
|
2018-01-05 12:35:43 +00:00
|
|
|
|
|
|
|
cc_library {
|
|
|
|
// NOTE: --exclude-libs=libgcc.a makes sure that any symbols ld-android.so pulls from
|
|
|
|
// libgcc.a are made static to ld-android.so. This in turn ensures that libraries that
|
|
|
|
// a) pull symbols from libgcc.a and b) depend on ld-android.so will not rely on ld-android.so
|
|
|
|
// to provide those symbols, but will instead pull them from libgcc.a. Specifically,
|
|
|
|
// we use this property to make sure libc.so has its own copy of the code from
|
|
|
|
// libgcc.a it uses.
|
|
|
|
//
|
|
|
|
// DO NOT REMOVE --exclude-libs!
|
|
|
|
|
2018-09-01 02:01:56 +00:00
|
|
|
ldflags: [
|
|
|
|
"-Wl,--exclude-libs=libgcc.a",
|
|
|
|
"-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
|
|
|
|
"-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
|
|
|
|
"-Wl,--exclude-libs=libclang_rt.builtins-x86-android.a",
|
|
|
|
"-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
|
|
|
|
],
|
2018-01-05 12:35:43 +00:00
|
|
|
|
|
|
|
// for x86, exclude libgcc_eh.a for the same reasons as above
|
|
|
|
arch: {
|
2018-01-05 13:31:44 +00:00
|
|
|
arm: {
|
|
|
|
version_script: "linker.arm.map",
|
|
|
|
},
|
|
|
|
arm64: {
|
|
|
|
version_script: "linker.generic.map",
|
|
|
|
},
|
2018-01-05 12:35:43 +00:00
|
|
|
x86: {
|
|
|
|
ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
|
2018-01-05 13:31:44 +00:00
|
|
|
version_script: "linker.generic.map",
|
2018-01-05 12:35:43 +00:00
|
|
|
},
|
|
|
|
x86_64: {
|
|
|
|
ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
|
2018-01-05 13:31:44 +00:00
|
|
|
version_script: "linker.generic.map",
|
|
|
|
},
|
|
|
|
mips: {
|
|
|
|
version_script: "linker.generic.map",
|
|
|
|
},
|
|
|
|
mips64: {
|
|
|
|
version_script: "linker.generic.map",
|
2018-01-05 12:35:43 +00:00
|
|
|
},
|
|
|
|
},
|
2018-01-05 13:31:44 +00:00
|
|
|
|
|
|
|
srcs: ["ld_android.cpp"],
|
2018-01-05 12:35:43 +00:00
|
|
|
cflags: [
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wunused",
|
|
|
|
"-Werror",
|
|
|
|
],
|
|
|
|
stl: "none",
|
|
|
|
|
|
|
|
name: "ld-android",
|
|
|
|
defaults: ["linux_bionic_supported"],
|
2018-04-27 12:53:11 +00:00
|
|
|
recovery_available: true,
|
2018-01-05 12:35:43 +00:00
|
|
|
|
2018-03-28 05:10:55 +00:00
|
|
|
nocrt: true,
|
2018-01-05 12:35:43 +00:00
|
|
|
system_shared_libs: [],
|
|
|
|
|
|
|
|
sanitize: {
|
|
|
|
never: true,
|
|
|
|
},
|
|
|
|
}
|