Merge "Add strip mode mini-debug-info."

am: 9a02623

* commit '9a02623eb66519a2b4607daa883607e893f7727f':
  Add strip mode mini-debug-info.

Change-Id: Ia856b0af684e62b2d17a4a92015afcb02992f523
This commit is contained in:
Yabin Cui 2016-04-16 00:33:39 +00:00 committed by android-build-merger
commit 3cb18efc4a
2 changed files with 23 additions and 1 deletions

View file

@ -1643,6 +1643,23 @@ $(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ \
$(if $(PRIVATE_NO_DEBUGLINK),,$(TARGET_STRIP_EXTRA))
endef
define transform-to-stripped-keep-mini-debug-info
@echo "target Strip (mini debug info): $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(hide) $(PRIVATE_NM) -D $< --format=posix --defined-only | awk '{ print $$1 }' | sort >$@.dynsyms
$(hide) $(PRIVATE_NM) $< --format=posix --defined-only | awk '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort >$@.funcsyms
$(hide) comm -13 $@.dynsyms $@.funcsyms >$@.keep_symbols
$(hide) $(PRIVATE_OBJCOPY) --only-keep-debug $< $@.debug
$(hide) $(PRIVATE_OBJCOPY) --rename-section .debug_frame=saved_debug_frame $@.debug $@.mini_debuginfo
$(hide) $(PRIVATE_OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$@.keep_symbols $@.mini_debuginfo
$(hide) $(PRIVATE_OBJCOPY) --rename-section saved_debug_frame=.debug_frame $@.mini_debuginfo
$(hide) $(PRIVATE_STRIP) --strip-all -R .comment $< -o $@
$(hide) rm -f $@.mini_debuginfo.xz
$(hide) xz $@.mini_debuginfo
$(hide) $(PRIVATE_OBJCOPY) --add-section .gnu_debugdata=$@.mini_debuginfo.xz $@
$(hide) rm -f $@.dynsyms $@.funcsyms $@.keep_symbols $@.debug $@.mini_debuginfo.xz
endef
define transform-to-stripped-keep-symbols
@echo "target Strip (keep symbols): $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)

View file

@ -121,6 +121,7 @@ endif
$(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_NM := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NM)
$(strip_output): PRIVATE_READELF := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_READELF)
ifeq ($(my_strip_module),no_debuglink)
$(strip_output): PRIVATE_NO_DEBUGLINK := true
@ -128,7 +129,11 @@ else
$(strip_output): PRIVATE_NO_DEBUGLINK :=
endif
ifneq ($(filter true no_debuglink,$(my_strip_module)),)
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)),)
# Strip the binary
$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
$(transform-to-stripped)