Merge "Convert linker from Android.mk to Android.bp"
This commit is contained in:
commit
cf85fd5fd5
|
@ -0,0 +1,144 @@
|
|||
cc_library_static {
|
||||
name: "liblinker_malloc",
|
||||
clang: true,
|
||||
|
||||
srcs: [
|
||||
"linker_allocator.cpp",
|
||||
"linker_memory.cpp",
|
||||
],
|
||||
|
||||
// We need to access Bionic private headers in the linker.
|
||||
include_dirs: ["bionic/libc"],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
clang: true,
|
||||
|
||||
srcs: [
|
||||
"dlfcn.cpp",
|
||||
"linker.cpp",
|
||||
"linker_block_allocator.cpp",
|
||||
"linker_gdb_support.cpp",
|
||||
"linker_libc_support.c",
|
||||
"linker_logger.cpp",
|
||||
"linker_mapped_file_fragment.cpp",
|
||||
"linker_phdr.cpp",
|
||||
"linker_sdk_versions.cpp",
|
||||
"linker_utils.cpp",
|
||||
"rt.cpp",
|
||||
],
|
||||
|
||||
arch: {
|
||||
arm: {
|
||||
srcs: ["arch/arm/begin.S"],
|
||||
|
||||
cflags: ["-D__work_around_b_24465209__"],
|
||||
},
|
||||
arm64: {
|
||||
srcs: ["arch/arm64/begin.S"],
|
||||
},
|
||||
x86: {
|
||||
srcs: ["arch/x86/begin.c"],
|
||||
|
||||
cflags: ["-D__work_around_b_24465209__"],
|
||||
},
|
||||
x86_64: {
|
||||
srcs: ["arch/x86_64/begin.S"],
|
||||
},
|
||||
mips: {
|
||||
srcs: [
|
||||
"arch/mips/begin.S",
|
||||
"linker_mips.cpp",
|
||||
],
|
||||
},
|
||||
mips64: {
|
||||
srcs: [
|
||||
"arch/mips64/begin.S",
|
||||
"linker_mips.cpp",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
// We need to access Bionic private headers in the linker.
|
||||
include_dirs: ["bionic/libc"],
|
||||
|
||||
// -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",
|
||||
],
|
||||
|
||||
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",
|
||||
],
|
||||
|
||||
conlyflags: ["-std=gnu99"],
|
||||
|
||||
cppflags: ["-Wold-style-cast"],
|
||||
|
||||
// we don't want crtbegin.o (because we have begin.o), so unset it
|
||||
// just for this module
|
||||
nocrt: true,
|
||||
|
||||
static_libs: [
|
||||
"libc_nomalloc",
|
||||
"libziparchive",
|
||||
"libutils",
|
||||
"libbase",
|
||||
"libz",
|
||||
"liblog",
|
||||
"libdebuggerd_client",
|
||||
|
||||
// Important: The liblinker_malloc should be the last library in the list
|
||||
// to overwrite any other malloc implementations by other static libraries.
|
||||
"liblinker_malloc"
|
||||
],
|
||||
static_executable: true,
|
||||
|
||||
name: "linker",
|
||||
multilib: {
|
||||
lib32: {
|
||||
symlinks: ["linker_asan"],
|
||||
},
|
||||
lib64: {
|
||||
suffix: "64",
|
||||
symlinks: ["linker_asan64"],
|
||||
},
|
||||
},
|
||||
target: {
|
||||
android64: {
|
||||
cflags: ["-DTARGET_IS_64_BIT"],
|
||||
},
|
||||
},
|
||||
compile_multilib: "both",
|
||||
|
||||
// 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_",
|
||||
}
|
|
@ -1,129 +1,3 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_CLANG := true
|
||||
|
||||
LOCAL_MODULE := liblinker_malloc
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
linker_allocator.cpp \
|
||||
linker_memory.cpp
|
||||
|
||||
# We need to access Bionic private headers in the linker.
|
||||
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_CLANG := true
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
dlfcn.cpp \
|
||||
linker.cpp \
|
||||
linker_block_allocator.cpp \
|
||||
linker_gdb_support.cpp \
|
||||
linker_libc_support.c \
|
||||
linker_logger.cpp \
|
||||
linker_mapped_file_fragment.cpp \
|
||||
linker_phdr.cpp \
|
||||
linker_sdk_versions.cpp \
|
||||
linker_utils.cpp \
|
||||
rt.cpp \
|
||||
|
||||
LOCAL_SRC_FILES_arm := arch/arm/begin.S
|
||||
LOCAL_SRC_FILES_arm64 := arch/arm64/begin.S
|
||||
LOCAL_SRC_FILES_x86 := arch/x86/begin.c
|
||||
LOCAL_SRC_FILES_x86_64 := arch/x86_64/begin.S
|
||||
LOCAL_SRC_FILES_mips := arch/mips/begin.S linker_mips.cpp
|
||||
LOCAL_SRC_FILES_mips64 := arch/mips64/begin.S linker_mips.cpp
|
||||
|
||||
# -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.
|
||||
LOCAL_LDFLAGS := \
|
||||
-shared \
|
||||
-Wl,-Bsymbolic \
|
||||
-Wl,--exclude-libs,ALL \
|
||||
|
||||
LOCAL_CFLAGS += \
|
||||
-fno-stack-protector \
|
||||
-Wstrict-overflow=5 \
|
||||
-fvisibility=hidden \
|
||||
-Wall -Wextra -Wunused -Werror \
|
||||
|
||||
LOCAL_CFLAGS_arm += -D__work_around_b_24465209__
|
||||
LOCAL_CFLAGS_x86 += -D__work_around_b_24465209__
|
||||
|
||||
LOCAL_CONLYFLAGS += \
|
||||
-std=gnu99 \
|
||||
|
||||
LOCAL_CPPFLAGS += \
|
||||
-Wold-style-cast \
|
||||
|
||||
ifeq ($(TARGET_IS_64_BIT),true)
|
||||
LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
|
||||
endif
|
||||
|
||||
# We need to access Bionic private headers in the linker.
|
||||
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
|
||||
|
||||
# we don't want crtbegin.o (because we have begin.o), so unset it
|
||||
# just for this module
|
||||
LOCAL_NO_CRT := true
|
||||
# TODO: split out the asflags.
|
||||
LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
|
||||
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libc_nomalloc \
|
||||
libziparchive \
|
||||
libutils \
|
||||
libbase \
|
||||
libz \
|
||||
liblog \
|
||||
libdebuggerd_client
|
||||
|
||||
# Important: The liblinker_malloc should be the last library in the list
|
||||
# to overwrite any other malloc implementations by other static libraries.
|
||||
LOCAL_STATIC_LIBRARIES += liblinker_malloc
|
||||
|
||||
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
||||
|
||||
LOCAL_MODULE := linker
|
||||
LOCAL_MODULE_STEM_32 := linker
|
||||
LOCAL_MODULE_STEM_64 := linker64
|
||||
LOCAL_MULTILIB := both
|
||||
|
||||
# Leave the symbols in the shared library so that stack unwinders can produce
|
||||
# meaningful name resolution.
|
||||
LOCAL_STRIP_MODULE := keep_symbols
|
||||
|
||||
# Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
|
||||
# looking up symbols in the linker by mistake.
|
||||
#
|
||||
# Note we are using "=" instead of ":=" to defer the evaluation,
|
||||
# because LOCAL_2ND_ARCH_VAR_PREFIX or linked_module isn't set properly yet at this point.
|
||||
LOCAL_POST_LINK_CMD = $(hide) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) \
|
||||
--prefix-symbols=__dl_ $(linked_module)
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
|
||||
define add-linker-symlink
|
||||
$(eval _from := $(TARGET_OUT)/bin/$(1))
|
||||
$(eval _to:=$(2))
|
||||
$(_from): $(LOCAL_MODULE_MAKEFILE)
|
||||
@echo "Symlink: $$@ -> $(_to)"
|
||||
@mkdir -p $$(dir $$@)
|
||||
@rm -rf $$@
|
||||
$(hide) ln -sf $(_to) $$@
|
||||
endef
|
||||
|
||||
$(eval $(call add-linker-symlink,linker_asan,linker))
|
||||
ifeq ($(TARGET_IS_64_BIT),true)
|
||||
$(eval $(call add-linker-symlink,linker_asan64,linker64))
|
||||
endif
|
||||
|
||||
include $(call first-makefiles-under,$(LOCAL_PATH))
|
||||
|
|
Loading…
Reference in New Issue