Merge "Call lld with --pack-dyn-relocs=none if my_pack_module_relocations is false"

am: 2a801b3cd7

Change-Id: I1feb0c37f35e925df94b8cc7566694259457b7da
This commit is contained in:
Chih-Hung Hsieh
2018-06-01 14:09:38 -07:00
committed by android-build-merger
3 changed files with 48 additions and 28 deletions

View File

@@ -519,6 +519,10 @@ my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)G
my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
ifeq ($(my_use_clang_lld),true)
my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LLDFLAGS)
include $(BUILD_SYSTEM)/pack_dyn_relocs_setup.mk
ifeq ($(my_pack_module_relocations),false)
my_target_global_ldflags += -Wl,--pack-dyn-relocs=none
endif
else
my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
endif # my_use_clang_lld

View File

@@ -35,6 +35,7 @@ ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
###################################
include $(BUILD_SYSTEM)/use_lld_setup.mk
include $(BUILD_SYSTEM)/binary.mk
###################################
@@ -44,35 +45,12 @@ include $(BUILD_SYSTEM)/binary.mk
relocation_packer_input := $(linked_module)
relocation_packer_output := $(intermediates)/PACKED/$(my_built_module_stem)
my_pack_module_relocations := false
ifneq ($(DISABLE_RELOCATION_PACKER),true)
my_pack_module_relocations := $(firstword \
$(LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
$(LOCAL_PACK_MODULE_RELOCATIONS))
endif
ifeq ($(my_pack_module_relocations),)
my_pack_module_relocations := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PACK_MODULE_RELOCATIONS)
endif
# Do not pack relocations for executables. Because packing results in
# non-zero p_vaddr which causes kernel to load executables to lower
# address (starting at 0x8000) http://b/20665974
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
my_pack_module_relocations := false
endif
# TODO (dimitry): Relocation packer is not yet available for darwin
ifneq ($(HOST_OS),linux)
my_pack_module_relocations := false
endif
# Relocation packer does not work with LLD yet.
ifeq ($(my_use_clang_lld),true)
my_pack_module_relocations := false
endif
include $(BUILD_SYSTEM)/pack_dyn_relocs_setup.mk
# Stand-alone relocation_packer does not work with LLD output,
# but it can be replaced by lld's --pack-dyn-relocs=android.
ifeq (true,$(my_pack_module_relocations))
ifeq (false,$(my_use_clang_lld))
# Pack relocations
$(relocation_packer_output): $(relocation_packer_input)
$(pack-elf-relocations)
@@ -80,7 +58,12 @@ else
$(relocation_packer_output): $(relocation_packer_input)
@echo "target Unpacked: $(PRIVATE_MODULE) ($@)"
$(copy-file-to-target)
endif
endif # my_use_clang_lld
else
$(relocation_packer_output): $(relocation_packer_input)
@echo "target Unpacked: $(PRIVATE_MODULE) ($@)"
$(copy-file-to-target)
endif # my_pack_module_relocations
###########################################################
## Store a copy with symbols for symbolic debugging

View File

@@ -0,0 +1,33 @@
#############################################################
## Set up my_pack_module_relocations
## Input variables:
## DISABLE_RELOCATION_PACKER,
## LOCAL_PACK_MODULE_RELOCATIONS*,
## *TARGET_PACK_MODULE_RELOCATIONS,
## LOCAL_MODULE_CLASS, HOST_OS
## Output variables:
## my_pack_module_relocations, if false skip relocation_packer
#############################################################
my_pack_module_relocations := false
ifneq ($(DISABLE_RELOCATION_PACKER),true)
my_pack_module_relocations := $(firstword \
$(LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
$(LOCAL_PACK_MODULE_RELOCATIONS))
endif
ifeq ($(my_pack_module_relocations),)
my_pack_module_relocations := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PACK_MODULE_RELOCATIONS)
endif
# Do not pack relocations for executables. Because packing results in
# non-zero p_vaddr which causes kernel to load executables to lower
# address (starting at 0x8000) http://b/20665974
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
my_pack_module_relocations := false
endif
# TODO (dimitry): Relocation packer is not yet available for darwin
ifneq ($(HOST_OS),linux)
my_pack_module_relocations := false
endif