diff options
author | Christopher Ferris <cferris@google.com> | 2014-03-18 14:50:09 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2014-03-18 17:34:41 -0700 |
commit | a6e2f9322c47ac02546aa436341fa42afd0000c5 (patch) | |
tree | d159588a6013b962458d7bff15d628ec7d65fcf0 /core | |
parent | bce52ca5fae5d0062e7622d758a3619f2279c666 (diff) | |
download | build-a6e2f9322c47ac02546aa436341fa42afd0000c5.zip build-a6e2f9322c47ac02546aa436341fa42afd0000c5.tar.gz build-a6e2f9322c47ac02546aa436341fa42afd0000c5.tar.bz2 |
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
Diffstat (limited to 'core')
-rw-r--r-- | core/combo/TARGET_linux-arm.mk | 8 | ||||
-rw-r--r-- | core/combo/TARGET_linux-arm64.mk | 8 | ||||
-rw-r--r-- | core/combo/TARGET_linux-mips.mk | 8 | ||||
-rw-r--r-- | core/combo/TARGET_linux-mips64.mk | 8 | ||||
-rw-r--r-- | core/combo/TARGET_linux-x86.mk | 9 | ||||
-rw-r--r-- | core/combo/TARGET_linux-x86_64.mk | 9 | ||||
-rw-r--r-- | core/definitions.mk | 6 | ||||
-rw-r--r-- | core/dynamic_binary.mk | 9 | ||||
-rw-r--r-- | core/strip.mk | 25 |
9 files changed, 52 insertions, 38 deletions
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index 213cae2..c2e4679 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -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 diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk index f130311..c04f2ca 100644 --- a/core/combo/TARGET_linux-arm64.mk +++ b/core/combo/TARGET_linux-arm64.mk @@ -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 diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk index 31e0b9a..8ba5959 100644 --- a/core/combo/TARGET_linux-mips.mk +++ b/core/combo/TARGET_linux-mips.mk @@ -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 diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk index 099edfa..c617ac1 100644 --- a/core/combo/TARGET_linux-mips64.mk +++ b/core/combo/TARGET_linux-mips64.mk @@ -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 diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk index 37795ff..c471e21 100644 --- a/core/combo/TARGET_linux-x86.mk +++ b/core/combo/TARGET_linux-x86.mk @@ -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 := \ diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk index 8e6a653..fbc0056 100644 --- a/core/combo/TARGET_linux-x86_64.mk +++ b/core/combo/TARGET_linux-x86_64.mk @@ -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 := \ diff --git a/core/definitions.mk b/core/definitions.mk index 9cbd647..d6cd9d1 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -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 diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk index 1d3b99e..32f2c91 100644 --- a/core/dynamic_binary.mk +++ b/core/dynamic_binary.mk @@ -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 diff --git a/core/strip.mk b/core/strip.mk new file mode 100644 index 0000000..906d90e --- /dev/null +++ b/core/strip.mk @@ -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) $< $@ |