2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Standard rules for building any target-side binaries
|
|
|
|
## with dynamic linkage (dynamic libraries or executables
|
|
|
|
## that link with dynamic libraries)
|
|
|
|
##
|
|
|
|
## Files including this file must define a rule to build
|
|
|
|
## the target $(linked_module).
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# This constraint means that we can hard-code any $(TARGET_*) variables.
|
|
|
|
ifdef LOCAL_IS_HOST_MODULE
|
|
|
|
$(error This file should not be used to build host binaries. Included by (or near) $(lastword $(filter-out config/%,$(MAKEFILE_LIST))))
|
|
|
|
endif
|
|
|
|
|
|
|
|
# The name of the target file, without any path prepended.
|
2014-03-22 03:27:37 +08:00
|
|
|
# This duplicates logic from base_rules.mk because we need to
|
|
|
|
# know its results before base_rules.mk is included.
|
|
|
|
include $(BUILD_SYSTEM)/configure_module_stem.mk
|
2009-03-04 11:28:42 +08:00
|
|
|
|
2014-12-19 06:53:52 +08:00
|
|
|
intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
# Define the target that is the unmodified output of the linker.
|
|
|
|
# The basename of this target must be the same as the final output
|
|
|
|
# binary name, because it's used to set the "soname" in the binary.
|
|
|
|
# The includer of this file will define a rule to build this target.
|
2017-05-20 05:20:02 +08:00
|
|
|
linked_module := $(intermediates)/LINKED/$(notdir $(my_installed_module_stem))
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
|
|
|
|
|
|
|
|
# Because TARGET_SYMBOL_FILTER_FILE depends on ALL_ORIGINAL_DYNAMIC_BINARIES,
|
|
|
|
# the linked_module rules won't necessarily inherit the PRIVATE_
|
|
|
|
# variables from LOCAL_BUILT_MODULE. This tells binary.make to explicitly
|
|
|
|
# define the PRIVATE_ variables for linked_module as well as for
|
|
|
|
# LOCAL_BUILT_MODULE.
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
|
|
|
|
|
|
|
|
###################################
|
|
|
|
include $(BUILD_SYSTEM)/binary.mk
|
|
|
|
###################################
|
|
|
|
|
2015-05-02 09:12:29 +08:00
|
|
|
###########################################################
|
|
|
|
## Pack relocation tables
|
|
|
|
###########################################################
|
|
|
|
relocation_packer_input := $(linked_module)
|
|
|
|
relocation_packer_output := $(intermediates)/PACKED/$(my_built_module_stem)
|
|
|
|
|
2015-11-13 07:27:49 +08:00
|
|
|
my_pack_module_relocations := false
|
|
|
|
ifneq ($(DISABLE_RELOCATION_PACKER),true)
|
2016-03-02 12:14:52 +08:00
|
|
|
my_pack_module_relocations := $(firstword \
|
|
|
|
$(LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
|
|
|
|
$(LOCAL_PACK_MODULE_RELOCATIONS))
|
2015-11-13 07:27:49 +08:00
|
|
|
endif
|
2015-05-02 09:12:29 +08:00
|
|
|
|
|
|
|
ifeq ($(my_pack_module_relocations),)
|
|
|
|
my_pack_module_relocations := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PACK_MODULE_RELOCATIONS)
|
|
|
|
endif
|
|
|
|
|
2015-04-30 03:13:37 +08:00
|
|
|
# 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
|
Add NATIVE_TESTS class, move host native tests
Host native tests have been getting installed into
out/host/linux-x86/bin/..., but this pollutes the bin directory with a
lot of poorly named tests. Also, to support 32-bit and 64-bit tests, we
need to have different names with different suffixes. This causes
problems when tests expect to be named something specific (like gtest).
It's also convenient to store test data next to the test itself.
So with this change, native tests will be installed in
out/host/linux-x86/nativetest[64]/$(LOCAL_MODULE)/$(LOCAL_MODULE_STEM)
just like target tests get installed into /data/nativetest[64].
Implement this using a new NATIVE_TESTS class, which is like
EXECUTABLES, but sets up the install path differently, and configures
the rpath to load shared libraries with the proper relative path.
LOCAL_MODULE_RELATIVE_PATH can be used to control the directory name, it
will default to $(LOCAL_MODULE). This way multiple related tests can be
grouped together.
Target native tests also use NATIVE_TESTS now, but nothing should change
other than LOCAL_MODULE_RELATIVE_PATH can be used.
Change-Id: I535e42b1a6b21c5b8d6a580aa2f944d2be35e27d
2016-03-03 05:54:51 +08:00
|
|
|
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
|
2015-05-02 09:12:29 +08:00
|
|
|
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
|
|
|
|
|
|
|
|
ifeq (true,$(my_pack_module_relocations))
|
|
|
|
# Pack relocations
|
2016-03-01 09:52:39 +08:00
|
|
|
$(relocation_packer_output): $(relocation_packer_input)
|
2015-05-02 09:12:29 +08:00
|
|
|
$(pack-elf-relocations)
|
|
|
|
else
|
2016-03-01 09:52:39 +08:00
|
|
|
$(relocation_packer_output): $(relocation_packer_input)
|
2015-05-02 09:12:29 +08:00
|
|
|
@echo "target Unpacked: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target)
|
|
|
|
endif
|
|
|
|
|
2011-03-15 02:44:57 +08:00
|
|
|
###########################################################
|
|
|
|
## Store a copy with symbols for symbolic debugging
|
|
|
|
###########################################################
|
2013-11-14 09:56:20 +08:00
|
|
|
ifeq ($(LOCAL_UNSTRIPPED_PATH),)
|
2014-01-24 07:09:04 +08:00
|
|
|
my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
|
|
|
|
else
|
|
|
|
my_unstripped_path := $(LOCAL_UNSTRIPPED_PATH)
|
2013-11-14 09:56:20 +08:00
|
|
|
endif
|
2015-05-02 09:12:29 +08:00
|
|
|
symbolic_input := $(relocation_packer_output)
|
2014-05-21 05:43:51 +08:00
|
|
|
symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
|
2016-03-01 09:52:39 +08:00
|
|
|
$(symbolic_output) : $(symbolic_input)
|
2011-03-15 02:44:57 +08:00
|
|
|
@echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target)
|
|
|
|
|
2015-09-24 16:40:52 +08:00
|
|
|
###########################################################
|
|
|
|
## Store breakpad symbols
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
|
2015-09-25 09:12:33 +08:00
|
|
|
my_breakpad_path := $(TARGET_OUT_BREAKPAD)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
|
2015-09-24 16:40:52 +08:00
|
|
|
breakpad_input := $(relocation_packer_output)
|
|
|
|
breakpad_output := $(my_breakpad_path)/$(my_installed_module_stem).sym
|
|
|
|
$(breakpad_output) : $(breakpad_input) | $(BREAKPAD_DUMP_SYMS)
|
|
|
|
@echo "target breakpad: $(PRIVATE_MODULE) ($@)"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(hide) $(BREAKPAD_DUMP_SYMS) -c $< > $@
|
|
|
|
$(LOCAL_BUILT_MODULE) : $(breakpad_output)
|
|
|
|
endif
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Strip
|
|
|
|
###########################################################
|
2011-03-15 02:44:57 +08:00
|
|
|
strip_input := $(symbolic_output)
|
2015-05-02 09:12:29 +08:00
|
|
|
strip_output := $(LOCAL_BUILT_MODULE)
|
2009-03-04 11:28:42 +08:00
|
|
|
|
2016-03-02 12:14:52 +08:00
|
|
|
my_strip_module := $(firstword \
|
|
|
|
$(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
|
|
|
|
$(LOCAL_STRIP_MODULE))
|
2014-03-17 03:43:49 +08:00
|
|
|
ifeq ($(my_strip_module),)
|
2016-04-27 07:08:00 +08:00
|
|
|
my_strip_module := mini-debug-info
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(my_strip_module),mini-debug-info)
|
|
|
|
# Don't use mini-debug-info on mips (both 32-bit and 64-bit). objcopy checks that all
|
|
|
|
# SH_MIPS_DWARF sections having name prefix .debug_ or .zdebug_, so there seems no easy
|
|
|
|
# way using objcopy to remove all debug sections except .debug_frame on mips.
|
|
|
|
ifneq ($(filter mips mips64,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
|
2016-04-19 11:38:34 +08:00
|
|
|
my_strip_module := true
|
2009-03-04 11:28:42 +08:00
|
|
|
endif
|
2016-04-27 07:08:00 +08:00
|
|
|
endif
|
2009-03-04 11:28:42 +08:00
|
|
|
|
2014-01-24 07:09:04 +08:00
|
|
|
$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
|
|
|
|
$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
|
2016-03-30 03:22:20 +08:00
|
|
|
$(strip_output): PRIVATE_NM := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NM)
|
2014-08-21 08:12:32 +08:00
|
|
|
$(strip_output): PRIVATE_READELF := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_READELF)
|
|
|
|
ifeq ($(my_strip_module),no_debuglink)
|
|
|
|
$(strip_output): PRIVATE_NO_DEBUGLINK := true
|
|
|
|
else
|
|
|
|
$(strip_output): PRIVATE_NO_DEBUGLINK :=
|
|
|
|
endif
|
|
|
|
|
2016-03-30 03:22:20 +08:00
|
|
|
ifeq ($(my_strip_module),mini-debug-info)
|
|
|
|
# Strip the binary, but keep debug frames and symbol table in a compressed .gnu_debugdata section.
|
|
|
|
$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NM)
|
|
|
|
$(transform-to-stripped-keep-mini-debug-info)
|
|
|
|
else ifneq ($(filter true no_debuglink,$(my_strip_module)),)
|
2014-08-21 08:12:32 +08:00
|
|
|
# Strip the binary
|
2014-01-24 07:09:04 +08:00
|
|
|
$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
|
2009-03-04 11:28:42 +08:00
|
|
|
$(transform-to-stripped)
|
2014-08-21 08:12:32 +08:00
|
|
|
else ifeq ($(my_strip_module),keep_symbols)
|
2014-03-19 05:50:09 +08:00
|
|
|
# Strip only the debug frames, but leave the symbol table.
|
|
|
|
$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
|
|
|
|
$(transform-to-stripped-keep-symbols)
|
2014-08-11 07:19:04 +08:00
|
|
|
|
|
|
|
# A product may be configured to strip everything in some build variants.
|
|
|
|
# We do the stripping as a post-install command so that LOCAL_BUILT_MODULE
|
|
|
|
# is still with the symbols and we don't need to clean it (and relink) when
|
|
|
|
# you switch build variant.
|
|
|
|
ifneq ($(filter $(STRIP_EVERYTHING_BUILD_VARIANTS),$(TARGET_BUILD_VARIANT)),)
|
|
|
|
$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := \
|
|
|
|
$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) --strip-all $(LOCAL_INSTALLED_MODULE)
|
|
|
|
endif
|
2014-03-19 05:50:09 +08:00
|
|
|
else
|
2009-03-04 11:28:42 +08:00
|
|
|
# Don't strip the binary, just copy it. We can't skip this step
|
|
|
|
# because a copy of the binary must appear at LOCAL_BUILT_MODULE.
|
2016-03-01 09:52:39 +08:00
|
|
|
$(strip_output): $(strip_input)
|
2009-03-04 11:28:42 +08:00
|
|
|
@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target)
|
2014-03-17 03:43:49 +08:00
|
|
|
endif # my_strip_module
|
2009-03-04 11:28:42 +08:00
|
|
|
|
2013-01-29 02:58:01 +08:00
|
|
|
$(cleantarget): PRIVATE_CLEAN_FILES += \
|
|
|
|
$(linked_module) \
|
2015-09-24 16:40:52 +08:00
|
|
|
$(breakpad_output) \
|
2015-04-21 07:59:05 +08:00
|
|
|
$(symbolic_output) \
|
|
|
|
$(strip_output)
|