aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRyan Prichard <rprichard@google.com>2018-03-27 22:15:45 -0700
committerRyan Prichard <rprichard@google.com>2018-04-04 15:56:28 -0700
commitd2cc96c24ad50127b12e9f259c946b3782bf49f7 (patch)
treea62d1ddae5017d268dabfa1bc798f0f2f2a4ffab /scripts
parentd452a42d9dadca384e50f309b05b586507c29b20 (diff)
downloadbuild_soong-d2cc96c24ad50127b12e9f259c946b3782bf49f7.tar.gz
build_soong-d2cc96c24ad50127b12e9f259c946b3782bf49f7.tar.bz2
build_soong-d2cc96c24ad50127b12e9f259c946b3782bf49f7.zip
Fix mini_debug_info stripping when no symbols should be kept.
If there are no symbols to keep (i.e. all function symbols are also in the dynsym table), then the "${outfile}.keep_symbols" file has size 0. When objcopy parses a --keep-symbols file, it has a special case for 0-sized files where it silently fails (exits with status 1, no error message). On the other hand, objcopy is happy with a file containing no symbols, as long as there is some whitespace or a comment. Avoid the special case by appending a newline to keep_symbols. Bug: b/62815515 Bug: b/77242617 Test: manual Change-Id: I90fd3258426176dc18aa5a8c19389c55fe6329c7 (cherry picked from commit afefacf196dbe9a178e6b0607bb01d3c088fa59d)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/strip.sh1
1 files changed, 1 insertions, 0 deletions
diff --git a/scripts/strip.sh b/scripts/strip.sh
index 848fe8d4..75e6994e 100755
--- a/scripts/strip.sh
+++ b/scripts/strip.sh
@@ -55,6 +55,7 @@ do_strip_keep_mini_debug_info() {
"${CROSS_COMPILE}nm" -D "${infile}" --format=posix --defined-only | awk '{ print $$1 }' | sort >"${outfile}.dynsyms"
"${CROSS_COMPILE}nm" "${infile}" --format=posix --defined-only | awk '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > "${outfile}.funcsyms"
comm -13 "${outfile}.dynsyms" "${outfile}.funcsyms" > "${outfile}.keep_symbols"
+ echo >> "${outfile}.keep_symbols" # Ensure that the keep_symbols file is not empty.
"${CROSS_COMPILE}objcopy" --rename-section .debug_frame=saved_debug_frame "${outfile}.debug" "${outfile}.mini_debuginfo"
"${CROSS_COMPILE}objcopy" -S --remove-section .gdb_index --remove-section .comment --keep-symbols="${outfile}.keep_symbols" "${outfile}.mini_debuginfo"
"${CROSS_COMPILE}objcopy" --rename-section saved_debug_frame=.debug_frame "${outfile}.mini_debuginfo"