From b43fe7a838ed44f61c6096023f9b66cccef69a17 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Fri, 17 May 2019 16:39:54 -0700 Subject: Add an option to preserve symbols and debug_frame. New strip option named keep_symbols_and_debug_frame, that will keep the symbols and the .debug_frame. This is meant for use by libc.so only on arm32. Other libraries might want to use it to keep better unwinding information on device. Bug: 132992102 Test: Built libc.so with this option and verified that it contains Test: the .debug_frame section. Change-Id: I823a28199dec8316e8b26fe31ff9f17e6b11d406 --- cc/builder.go | 14 +++++++++----- cc/strip.go | 13 ++++++++----- scripts/strip.sh | 34 +++++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/cc/builder.go b/cc/builder.go index c99e4618..0a286725 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -254,11 +254,12 @@ type builderFlags struct { groupStaticLibs bool - stripKeepSymbols bool - stripKeepSymbolsList string - stripKeepMiniDebugInfo bool - stripAddGnuDebuglink bool - stripUseGnuStrip bool + stripKeepSymbols bool + stripKeepSymbolsList string + stripKeepSymbolsAndDebugFrame bool + stripKeepMiniDebugInfo bool + stripAddGnuDebuglink bool + stripUseGnuStrip bool proto android.ProtoFlags protoC bool @@ -839,6 +840,9 @@ func TransformStrip(ctx android.ModuleContext, inputFile android.Path, if flags.stripKeepSymbolsList != "" { args += " -k" + flags.stripKeepSymbolsList } + if flags.stripKeepSymbolsAndDebugFrame { + args += " --keep-symbols-and-debug-frame" + } if flags.stripUseGnuStrip { args += " --use-gnu-strip" } diff --git a/cc/strip.go b/cc/strip.go index 7122585e..4daa7593 100644 --- a/cc/strip.go +++ b/cc/strip.go @@ -22,11 +22,12 @@ import ( type StripProperties struct { Strip struct { - None *bool `android:"arch_variant"` - All *bool `android:"arch_variant"` - Keep_symbols *bool `android:"arch_variant"` - Keep_symbols_list []string `android:"arch_variant"` - Use_gnu_strip *bool `android:"arch_variant"` + None *bool `android:"arch_variant"` + All *bool `android:"arch_variant"` + Keep_symbols *bool `android:"arch_variant"` + Keep_symbols_list []string `android:"arch_variant"` + Keep_symbols_and_debug_frame *bool `android:"arch_variant"` + Use_gnu_strip *bool `android:"arch_variant"` } `android:"arch_variant"` } @@ -46,6 +47,8 @@ func (stripper *stripper) strip(ctx ModuleContext, in android.Path, out android. } else { if Bool(stripper.StripProperties.Strip.Keep_symbols) { flags.stripKeepSymbols = true + } else if Bool(stripper.StripProperties.Strip.Keep_symbols_and_debug_frame) { + flags.stripKeepSymbolsAndDebugFrame = true } else if len(stripper.StripProperties.Strip.Keep_symbols_list) > 0 { flags.stripKeepSymbolsList = strings.Join(stripper.StripProperties.Strip.Keep_symbols_list, ",") } else if !Bool(stripper.StripProperties.Strip.All) { diff --git a/scripts/strip.sh b/scripts/strip.sh index 0f77da8a..bd62619b 100755 --- a/scripts/strip.sh +++ b/scripts/strip.sh @@ -28,6 +28,7 @@ # --add-gnu-debuglink # --keep-mini-debug-info # --keep-symbols +# --keep-symbols-and-debug-frame # --use-gnu-strip # --remove-build-id @@ -39,11 +40,12 @@ usage() { cat <