Add a method to leave the symbol table in a library.
When LOCAL_STRIP_MODULE := keep_symbols is set, then the normal strip rules will be modified so that only the .debug_* sections are removed. The original symbol table is left alone. This allows the compilation of certain libraries so that libbacktrace library can provide meaningful names to functions. Bug: 12958251 Change-Id: I82bdc304a463012e29086325ccb51163464cb4a9
This commit is contained in:
parent
bce52ca5fa
commit
a6e2f9322c
|
@ -58,13 +58,9 @@ $(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PRE
|
|||
$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
|
||||
ifeq ($(TARGET_BUILD_VARIANT),user)
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@
|
||||
else
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@ && \
|
||||
$(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@
|
||||
endif
|
||||
include $(BUILD_SYSTEM)/strip.mk
|
||||
|
||||
$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
|
||||
|
||||
|
|
|
@ -60,13 +60,9 @@ TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
|
|||
TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
|
||||
ifeq ($(TARGET_BUILD_VARIANT),user)
|
||||
TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@
|
||||
else
|
||||
TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@ && \
|
||||
$(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@
|
||||
endif
|
||||
include $(BUILD_SYSTEM)/strip.mk
|
||||
|
||||
TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
|
||||
|
||||
|
|
|
@ -58,13 +58,9 @@ $(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PRE
|
|||
$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
|
||||
ifeq ($(TARGET_BUILD_VARIANT),user)
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@
|
||||
else
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@ && \
|
||||
$(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@
|
||||
endif
|
||||
include $(BUILD_SYSTEM)/strip.mk
|
||||
|
||||
$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
|
||||
|
||||
|
|
|
@ -63,13 +63,9 @@ TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
|
|||
TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
|
||||
ifeq ($(TARGET_BUILD_VARIANT),user)
|
||||
TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-all $< -o $@
|
||||
else
|
||||
TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-all $< -o $@ && \
|
||||
$(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@
|
||||
endif
|
||||
include $(BUILD_SYSTEM)/strip.mk
|
||||
|
||||
TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
|
||||
|
||||
|
|
|
@ -51,14 +51,9 @@ $(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PRE
|
|||
$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
ifeq ($(TARGET_BUILD_VARIANT),user)
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@
|
||||
else
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@ && \
|
||||
$(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@
|
||||
endif
|
||||
include $(BUILD_SYSTEM)/strip.mk
|
||||
|
||||
ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
|
||||
$(combo_2nd_arch_prefix)TARGET_LIBGCC := \
|
||||
|
|
|
@ -53,14 +53,9 @@ TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
|
|||
TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
|
||||
TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
|
||||
|
||||
ifeq ($(TARGET_BUILD_VARIANT),user)
|
||||
TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@
|
||||
else
|
||||
TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@ && \
|
||||
$(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@
|
||||
endif
|
||||
include $(BUILD_SYSTEM)/strip.mk
|
||||
|
||||
ifneq ($(wildcard $(TARGET_CC)),)
|
||||
TARGET_LIBGCC := \
|
||||
|
|
|
@ -1327,6 +1327,12 @@ define transform-to-stripped
|
|||
$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_STRIP_COMMAND)
|
||||
endef
|
||||
|
||||
define transform-to-stripped-keep-symbols
|
||||
@mkdir -p $(dir $@)
|
||||
@echo "target Strip (keep symbols): $(PRIVATE_MODULE) ($@)"
|
||||
$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_STRIP_KEEP_SYMBOLS_COMMAND)
|
||||
endef
|
||||
|
||||
|
||||
###########################################################
|
||||
## Commands for running gcc to link an executable
|
||||
|
|
|
@ -116,6 +116,14 @@ $(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)
|
||||
$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
|
||||
$(transform-to-stripped-keep-symbols)
|
||||
else
|
||||
# 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.
|
||||
#
|
||||
|
@ -130,6 +138,7 @@ $(strip_output): $(strip_input)
|
|||
@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
|
||||
$(copy-file-to-target-with-cp)
|
||||
endif
|
||||
endif
|
||||
endif # my_strip_module
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Copyright (C) 2014 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
ifneq ($(TARGET_BUILD_VARIANT),user)
|
||||
TARGET_STRIP_EXTRA = && $(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@
|
||||
TARGET_STRIP_KEEP_SYMBOLS_EXTRA = --add-gnu-debuglink=$<
|
||||
endif
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP_COMMAND = $(PRIVATE_STRIP) --strip-all $< -o $@ $(TARGET_STRIP_EXTRA)
|
||||
$(combo_2nd_arch_prefix)TARGET_STRIP_KEEP_SYMBOLS_COMMAND = \
|
||||
$(PRIVATE_OBJCOPY) \
|
||||
`$(PRIVATE_READELF) -S $< | awk '/.debug_/ {print "-R " $$2}' | xargs` \
|
||||
$(TARGET_STRIP_KEEP_SYMBOLS_EXTRA) $< $@
|
Loading…
Reference in New Issue