diff options
author | Christopher Ferris | 2019-05-21 13:09:08 -0500 |
---|---|---|
committer | Gerrit Code Review | 2019-05-21 13:09:08 -0500 |
commit | 8a7469a0d7d390b76ede3bd830065575571502d5 (patch) | |
tree | 67cb3709e8fd719a1fd7650cf1ae2949dba4c960 | |
parent | 3f3a70c0ecb212d9e18e24dd1c31fc196a189eb9 (diff) | |
parent | b43fe7a838ed44f61c6096023f9b66cccef69a17 (diff) | |
download | platform-build-soong-8a7469a0d7d390b76ede3bd830065575571502d5.tar.gz platform-build-soong-8a7469a0d7d390b76ede3bd830065575571502d5.tar.xz platform-build-soong-8a7469a0d7d390b76ede3bd830065575571502d5.zip |
Merge "Add an option to preserve symbols and debug_frame."
-rw-r--r-- | cc/builder.go | 14 | ||||
-rw-r--r-- | cc/strip.go | 13 | ||||
-rwxr-xr-x | scripts/strip.sh | 34 |
3 files changed, 46 insertions, 15 deletions
diff --git a/cc/builder.go b/cc/builder.go index 8d09a99e..5fa0fad6 100644 --- a/cc/builder.go +++ b/cc/builder.go | |||
@@ -267,11 +267,12 @@ type builderFlags struct { | |||
267 | 267 | ||
268 | groupStaticLibs bool | 268 | groupStaticLibs bool |
269 | 269 | ||
270 | stripKeepSymbols bool | 270 | stripKeepSymbols bool |
271 | stripKeepSymbolsList string | 271 | stripKeepSymbolsList string |
272 | stripKeepMiniDebugInfo bool | 272 | stripKeepSymbolsAndDebugFrame bool |
273 | stripAddGnuDebuglink bool | 273 | stripKeepMiniDebugInfo bool |
274 | stripUseGnuStrip bool | 274 | stripAddGnuDebuglink bool |
275 | stripUseGnuStrip bool | ||
275 | 276 | ||
276 | proto android.ProtoFlags | 277 | proto android.ProtoFlags |
277 | protoC bool | 278 | protoC bool |
@@ -852,6 +853,9 @@ func TransformStrip(ctx android.ModuleContext, inputFile android.Path, | |||
852 | if flags.stripKeepSymbolsList != "" { | 853 | if flags.stripKeepSymbolsList != "" { |
853 | args += " -k" + flags.stripKeepSymbolsList | 854 | args += " -k" + flags.stripKeepSymbolsList |
854 | } | 855 | } |
856 | if flags.stripKeepSymbolsAndDebugFrame { | ||
857 | args += " --keep-symbols-and-debug-frame" | ||
858 | } | ||
855 | if flags.stripUseGnuStrip { | 859 | if flags.stripUseGnuStrip { |
856 | args += " --use-gnu-strip" | 860 | args += " --use-gnu-strip" |
857 | } | 861 | } |
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 ( | |||
22 | 22 | ||
23 | type StripProperties struct { | 23 | type StripProperties struct { |
24 | Strip struct { | 24 | Strip struct { |
25 | None *bool `android:"arch_variant"` | 25 | None *bool `android:"arch_variant"` |
26 | All *bool `android:"arch_variant"` | 26 | All *bool `android:"arch_variant"` |
27 | Keep_symbols *bool `android:"arch_variant"` | 27 | Keep_symbols *bool `android:"arch_variant"` |
28 | Keep_symbols_list []string `android:"arch_variant"` | 28 | Keep_symbols_list []string `android:"arch_variant"` |
29 | Use_gnu_strip *bool `android:"arch_variant"` | 29 | Keep_symbols_and_debug_frame *bool `android:"arch_variant"` |
30 | Use_gnu_strip *bool `android:"arch_variant"` | ||
30 | } `android:"arch_variant"` | 31 | } `android:"arch_variant"` |
31 | } | 32 | } |
32 | 33 | ||
@@ -46,6 +47,8 @@ func (stripper *stripper) strip(ctx ModuleContext, in android.Path, out android. | |||
46 | } else { | 47 | } else { |
47 | if Bool(stripper.StripProperties.Strip.Keep_symbols) { | 48 | if Bool(stripper.StripProperties.Strip.Keep_symbols) { |
48 | flags.stripKeepSymbols = true | 49 | flags.stripKeepSymbols = true |
50 | } else if Bool(stripper.StripProperties.Strip.Keep_symbols_and_debug_frame) { | ||
51 | flags.stripKeepSymbolsAndDebugFrame = true | ||
49 | } else if len(stripper.StripProperties.Strip.Keep_symbols_list) > 0 { | 52 | } else if len(stripper.StripProperties.Strip.Keep_symbols_list) > 0 { |
50 | flags.stripKeepSymbolsList = strings.Join(stripper.StripProperties.Strip.Keep_symbols_list, ",") | 53 | flags.stripKeepSymbolsList = strings.Join(stripper.StripProperties.Strip.Keep_symbols_list, ",") |
51 | } else if !Bool(stripper.StripProperties.Strip.All) { | 54 | } 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 @@ | |||
28 | # --add-gnu-debuglink | 28 | # --add-gnu-debuglink |
29 | # --keep-mini-debug-info | 29 | # --keep-mini-debug-info |
30 | # --keep-symbols | 30 | # --keep-symbols |
31 | # --keep-symbols-and-debug-frame | ||
31 | # --use-gnu-strip | 32 | # --use-gnu-strip |
32 | # --remove-build-id | 33 | # --remove-build-id |
33 | 34 | ||
@@ -39,11 +40,12 @@ usage() { | |||
39 | cat <<EOF | 40 | cat <<EOF |
40 | Usage: strip.sh [options] -k symbols -i in-file -o out-file -d deps-file | 41 | Usage: strip.sh [options] -k symbols -i in-file -o out-file -d deps-file |
41 | Options: | 42 | Options: |
42 | --add-gnu-debuglink Add a gnu-debuglink section to out-file | 43 | --add-gnu-debuglink Add a gnu-debuglink section to out-file |
43 | --keep-mini-debug-info Keep compressed debug info in out-file | 44 | --keep-mini-debug-info Keep compressed debug info in out-file |
44 | --keep-symbols Keep symbols in out-file | 45 | --keep-symbols Keep symbols in out-file |
45 | --use-gnu-strip Use strip/objcopy instead of llvm-{strip,objcopy} | 46 | --keep-symbols-and-debug-frame Keep symbols and .debug_frame in out-file |
46 | --remove-build-id Remove the gnu build-id section in out-file | 47 | --use-gnu-strip Use strip/objcopy instead of llvm-{strip,objcopy} |
48 | --remove-build-id Remove the gnu build-id section in out-file | ||
47 | EOF | 49 | EOF |
48 | exit 1 | 50 | exit 1 |
49 | } | 51 | } |
@@ -63,6 +65,15 @@ do_strip() { | |||
63 | fi | 65 | fi |
64 | } | 66 | } |
65 | 67 | ||
68 | do_strip_keep_symbols_and_debug_frame() { | ||
69 | REMOVE_SECTIONS=`"${CROSS_COMPILE}readelf" -S "${infile}" | awk '/.debug_/ {if ($2 != ".debug_frame") {print "--remove-section " $2}}' | xargs` | ||
70 | if [ -z "${use_gnu_strip}" ]; then | ||
71 | "${CLANG_BIN}/llvm-objcopy" "${infile}" "${outfile}.tmp" ${REMOVE_SECTIONS} | ||
72 | else | ||
73 | "${CROSS_COMPILE}objcopy" "${infile}" "${outfile}.tmp" ${REMOVE_SECTIONS} | ||
74 | fi | ||
75 | } | ||
76 | |||
66 | do_strip_keep_symbols() { | 77 | do_strip_keep_symbols() { |
67 | REMOVE_SECTIONS=`"${CROSS_COMPILE}readelf" -S "${infile}" | awk '/.debug_/ {print "--remove-section " $2}' | xargs` | 78 | REMOVE_SECTIONS=`"${CROSS_COMPILE}readelf" -S "${infile}" | awk '/.debug_/ {print "--remove-section " $2}' | xargs` |
68 | if [ -z "${use_gnu_strip}" ]; then | 79 | if [ -z "${use_gnu_strip}" ]; then |
@@ -148,6 +159,7 @@ while getopts $OPTSTRING opt; do | |||
148 | add-gnu-debuglink) add_gnu_debuglink=true ;; | 159 | add-gnu-debuglink) add_gnu_debuglink=true ;; |
149 | keep-mini-debug-info) keep_mini_debug_info=true ;; | 160 | keep-mini-debug-info) keep_mini_debug_info=true ;; |
150 | keep-symbols) keep_symbols=true ;; | 161 | keep-symbols) keep_symbols=true ;; |
162 | keep-symbols-and-debug-frame) keep_symbols_and_debug_frame=true ;; | ||
151 | remove-build-id) remove_build_id=true ;; | 163 | remove-build-id) remove_build_id=true ;; |
152 | use-gnu-strip) use_gnu_strip=true ;; | 164 | use-gnu-strip) use_gnu_strip=true ;; |
153 | *) echo "Unknown option --${OPTARG}"; usage ;; | 165 | *) echo "Unknown option --${OPTARG}"; usage ;; |
@@ -177,6 +189,16 @@ if [ ! -z "${keep_symbols}" -a ! -z "${keep_mini_debug_info}" ]; then | |||
177 | usage | 189 | usage |
178 | fi | 190 | fi |
179 | 191 | ||
192 | if [ ! -z "${keep_symbols}" -a ! -z "${keep_symbols_and_debug_frame}" ]; then | ||
193 | echo "--keep-symbols and --keep-symbols-and-debug-frame cannot be used together" | ||
194 | usage | ||
195 | fi | ||
196 | |||
197 | if [ ! -z "${keep_mini_debug_info}" -a ! -z "${keep_symbols_and_debug_frame}" ]; then | ||
198 | echo "--keep-symbols-mini-debug-info and --keep-symbols-and-debug-frame cannot be used together" | ||
199 | usage | ||
200 | fi | ||
201 | |||
180 | if [ ! -z "${symbols_to_keep}" -a ! -z "${keep_symbols}" ]; then | 202 | if [ ! -z "${symbols_to_keep}" -a ! -z "${keep_symbols}" ]; then |
181 | echo "--keep-symbols and -k cannot be used together" | 203 | echo "--keep-symbols and -k cannot be used together" |
182 | usage | 204 | usage |
@@ -195,6 +217,8 @@ elif [ ! -z "${symbols_to_keep}" ]; then | |||
195 | do_strip_keep_symbol_list | 217 | do_strip_keep_symbol_list |
196 | elif [ ! -z "${keep_mini_debug_info}" ]; then | 218 | elif [ ! -z "${keep_mini_debug_info}" ]; then |
197 | do_strip_keep_mini_debug_info | 219 | do_strip_keep_mini_debug_info |
220 | elif [ ! -z "${keep_symbols_and_debug_frame}" ]; then | ||
221 | do_strip_keep_symbols_and_debug_frame | ||
198 | else | 222 | else |
199 | do_strip | 223 | do_strip |
200 | fi | 224 | fi |