Strip prebuilt shared library by default.

Strip prebuilt shared library but not try adding gnu debuglink.
It would fail if you try run the adding gnu debuglink command if a
prebuilt is already stripped.

Bug: 17177288
Change-Id: If5811865715c2437e45fbd329983ef1212ef0109
This commit is contained in:
Ying Wang 2014-08-20 17:12:32 -07:00
parent df71e5b1c5
commit bfb52a2ec1
4 changed files with 23 additions and 14 deletions

View File

@ -1353,7 +1353,8 @@ endif
define transform-to-stripped
@mkdir -p $(dir $@)
@echo "target Strip: $(PRIVATE_MODULE) ($@)"
$(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ $(TARGET_STRIP_EXTRA)
$(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ \
$(if $(PRIVATE_NO_DEBUGLINK),,$(TARGET_STRIP_EXTRA))
endef
define transform-to-stripped-keep-symbols

View File

@ -96,18 +96,21 @@ ifeq ($(my_strip_module),)
my_strip_module := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP_MODULE)
endif
ifeq ($(my_strip_module),true)
# Strip the binary
$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
$(transform-to-stripped)
else
ifeq ($(my_strip_module),keep_symbols)
# Strip only the debug frames, but leave the symbol table.
$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
$(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
ifneq ($(filter true no_debuglink,$(my_strip_module)),)
# Strip the binary
$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
$(transform-to-stripped)
else ifeq ($(my_strip_module),keep_symbols)
# 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)
@ -134,7 +137,6 @@ $(strip_output): $(strip_input)
@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
$(copy-file-to-target-with-cp)
endif
endif
endif # my_strip_module

View File

@ -76,8 +76,7 @@ $(foreach t,$(1), \
) \
) \
$(eval LOCAL_MODULE_SUFFIX := $(suffix $(LOCAL_SRC_FILES))) \
$(if $(filter user,$(TARGET_BUILD_VARIANT)), \
$(eval LOCAL_STRIP_MODULE := $(8))) \
$(eval LOCAL_STRIP_MODULE := $(8)) \
$(eval include $(BUILD_PREBUILT)) \
)
endef

View File

@ -39,6 +39,10 @@ ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
# Put the built targets of all shared libraries in a common directory
# to simplify the link line.
OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_STRIP_MODULE),)
# Strip but not try to add debuglink
LOCAL_STRIP_MODULE := no_debuglink
endif
endif
ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
@ -59,7 +63,7 @@ LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
endif
ifeq ($(LOCAL_STRIP_MODULE),true)
ifneq ($(filter true no_debuglink,$(LOCAL_STRIP_MODULE)),)
ifdef LOCAL_IS_HOST_MODULE
$(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
endif
@ -71,6 +75,7 @@ ifeq ($(LOCAL_STRIP_MODULE),true)
endif
include $(BUILD_SYSTEM)/dynamic_binary.mk
built_module := $(linked_module)
else # LOCAL_STRIP_MODULE not true
include $(BUILD_SYSTEM)/base_rules.mk
built_module := $(LOCAL_BUILT_MODULE)
@ -109,6 +114,8 @@ $(LOCAL_BUILT_MODULE) : $(built_shared_libraries)
endif
endif
# We need to enclose the above export_includes and built_shared_libraries in
# "LOCAL_STRIP_MODULE not true" because otherwise the rules are defined in dynamic_binary.mk.
endif # LOCAL_STRIP_MODULE not true
ifeq ($(LOCAL_MODULE_CLASS),APPS)