From 979f9f9b180985e651c92c520364c5054e21d7d2 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 25 Jun 2018 12:33:35 -0700 Subject: [PATCH] Disable standalone relocation packer We only support relocation packing inside lld now, remove calls to the standalone relocation packer. Any shared library built with LOCAL_USE_CLANG_LLD := false will no longer have relocation packing. This will also prevent relocation packing on prebuilt shared libraries. Also enables relocation packing on Darwin since lld will work on Darwin. Bug: 110715614 Test: m checkbuild Change-Id: Ib4d4bc86f164d05dd78455c8e7605d4b4f5a2a77 --- core/config.mk | 3 --- core/definitions.mk | 10 ---------- core/dynamic_binary.mk | 26 ++------------------------ core/pack_dyn_relocs_setup.mk | 7 ++++--- core/prebuilt_internal.mk | 25 +++---------------------- 5 files changed, 9 insertions(+), 62 deletions(-) diff --git a/core/config.mk b/core/config.mk index 30459295dc..5562fe3a1a 100644 --- a/core/config.mk +++ b/core/config.mk @@ -710,9 +710,6 @@ DEXDUMP := $(HOST_OUT_EXECUTABLES)/dexdump2$(BUILD_EXECUTABLE_SUFFIX) PROFMAN := $(HOST_OUT_EXECUTABLES)/profman HIDDENAPI := $(HOST_OUT_EXECUTABLES)/hiddenapi -# relocation packer -RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation_packer/relocation_packer - FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin FINDBUGS := $(FINDBUGS_DIR)/findbugs diff --git a/core/definitions.mk b/core/definitions.mk index 9f958fa80a..6ab52f0484 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1897,16 +1897,6 @@ $(hide) $(PRIVATE_OBJCOPY_ADD_SECTION) \ $(TARGET_STRIP_KEEP_SYMBOLS_EXTRA) $< $@ endef -########################################################### -## Commands for packing a target executable or library -########################################################### - -define pack-elf-relocations -@echo "$($(PRIVATE_PREFIX)DISPLAY) Pack Relocations: $(PRIVATE_MODULE) ($@)" -$(copy-file-to-target) -$(hide) $(RELOCATION_PACKER) $@ -endef - ########################################################### ## Commands for running gcc to link an executable ########################################################### diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk index 939af33bd5..2f9c8ff51e 100644 --- a/core/dynamic_binary.mk +++ b/core/dynamic_binary.mk @@ -39,28 +39,6 @@ include $(BUILD_SYSTEM)/use_lld_setup.mk include $(BUILD_SYSTEM)/binary.mk ################################### -########################################################### -## Pack relocation tables -########################################################### -relocation_packer_input := $(linked_module) -relocation_packer_output := $(intermediates)/PACKED/$(my_built_module_stem) - -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) -else -relocation_packer_output := $(relocation_packer_input) -endif # my_use_clang_lld -else -relocation_packer_output := $(relocation_packer_input) -endif # my_pack_module_relocations - ########################################################### ## Store a copy with symbols for symbolic debugging ########################################################### @@ -69,7 +47,7 @@ my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(m else my_unstripped_path := $(LOCAL_UNSTRIPPED_PATH) endif -symbolic_input := $(relocation_packer_output) +symbolic_input := $(linked_module) symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem) $(symbolic_output) : $(symbolic_input) @echo "target Symbolic: $(PRIVATE_MODULE) ($@)" @@ -81,7 +59,7 @@ $(symbolic_output) : $(symbolic_input) ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true) my_breakpad_path := $(TARGET_OUT_BREAKPAD)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) -breakpad_input := $(relocation_packer_output) +breakpad_input := $(linked_module) breakpad_output := $(my_breakpad_path)/$(my_installed_module_stem).sym $(breakpad_output) : $(breakpad_input) | $(BREAKPAD_DUMP_SYMS) $(PRIVATE_READELF) @echo "target breakpad: $(PRIVATE_MODULE) ($@)" diff --git a/core/pack_dyn_relocs_setup.mk b/core/pack_dyn_relocs_setup.mk index 2147f44706..c5564b1eca 100644 --- a/core/pack_dyn_relocs_setup.mk +++ b/core/pack_dyn_relocs_setup.mk @@ -5,6 +5,7 @@ ## LOCAL_PACK_MODULE_RELOCATIONS*, ## *TARGET_PACK_MODULE_RELOCATIONS, ## LOCAL_MODULE_CLASS, HOST_OS +## LOCAL_IS_HOST_MODULE ## Output variables: ## my_pack_module_relocations, if false skip relocation_packer ############################################################# @@ -23,11 +24,11 @@ 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)),) +ifeq ($(filter SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),) my_pack_module_relocations := false endif -# TODO (dimitry): Relocation packer is not yet available for darwin -ifneq ($(HOST_OS),linux) +ifdef LOCAL_IS_HOST_MODULE + # Do not pack relocations on host modules my_pack_module_relocations := false endif diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index d5b7877a1d..f82af2fc62 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -42,9 +42,6 @@ LOCAL_CHECKED_MODULE := $(my_prebuilt_src_file) my_strip_module := $(firstword \ $(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \ $(LOCAL_STRIP_MODULE)) -my_pack_module_relocations := $(firstword \ - $(LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \ - $(LOCAL_PACK_MODULE_RELOCATIONS)) ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)) # LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES indicates that this prebuilt should be @@ -63,21 +60,6 @@ ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)) # Strip but not try to add debuglink my_strip_module := no_debuglink endif - - ifeq ($(LOCAL_IS_HOST_MODULE)$(my_pack_module_relocations),) - # Do not pack relocations by default - my_pack_module_relocations := false - endif - - ifeq ($(DISABLE_RELOCATION_PACKER),true) - my_pack_module_relocations := false - endif - - # Relocation packer does not work with LLD yet. - # my_use_clang_lld might be used before being set up in binary.mk - ifeq ($(my_use_clang_lld),true) - my_pack_module_relocations := false - endif endif ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),) @@ -141,7 +123,7 @@ $(error $(LOCAL_MODULE) : LOCAL_COMPRESSED_MODULE can only be defined for module endif # LOCAL_COMPRESSED_MODULE endif -ifneq ($(filter true keep_symbols no_debuglink mini-debug-info,$(my_strip_module) $(my_pack_module_relocations)),) +ifneq ($(filter true keep_symbols no_debuglink mini-debug-info,$(my_strip_module)),) ifdef LOCAL_IS_HOST_MODULE $(error Cannot strip/pack host module LOCAL_PATH=$(LOCAL_PATH)) endif @@ -151,13 +133,12 @@ ifneq ($(filter true keep_symbols no_debuglink mini-debug-info,$(my_strip_module ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) $(error Cannot strip/pack scripts LOCAL_PATH=$(LOCAL_PATH)) endif - # Set the arch-specific variables to set up the strip/pack rules. + # Set the arch-specific variables to set up the strip rules LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_strip_module) - LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_pack_module_relocations) include $(BUILD_SYSTEM)/dynamic_binary.mk built_module := $(linked_module) -else # my_strip_module and my_pack_module_relocations not true +else # my_strip_module not true include $(BUILD_SYSTEM)/base_rules.mk built_module := $(LOCAL_BUILT_MODULE)