aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2019-05-17 16:39:54 -0700
committerChristopher Ferris <cferris@google.com>2019-05-17 17:52:18 -0700
commitb43fe7a838ed44f61c6096023f9b66cccef69a17 (patch)
treebb7a6c7403f4dc958c9044d697db380c447d379b /scripts
parent4c83b8950af48bd503c89988f4de7c6c41023c71 (diff)
downloadbuild_soong-b43fe7a838ed44f61c6096023f9b66cccef69a17.tar.gz
build_soong-b43fe7a838ed44f61c6096023f9b66cccef69a17.tar.bz2
build_soong-b43fe7a838ed44f61c6096023f9b66cccef69a17.zip
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
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/strip.sh34
1 files changed, 29 insertions, 5 deletions
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 <<EOF
Usage: strip.sh [options] -k symbols -i in-file -o out-file -d deps-file
Options:
- --add-gnu-debuglink Add a gnu-debuglink section to out-file
- --keep-mini-debug-info Keep compressed debug info in out-file
- --keep-symbols Keep symbols in out-file
- --use-gnu-strip Use strip/objcopy instead of llvm-{strip,objcopy}
- --remove-build-id Remove the gnu build-id section in out-file
+ --add-gnu-debuglink Add a gnu-debuglink section to out-file
+ --keep-mini-debug-info Keep compressed debug info in out-file
+ --keep-symbols Keep symbols in out-file
+ --keep-symbols-and-debug-frame Keep symbols and .debug_frame in out-file
+ --use-gnu-strip Use strip/objcopy instead of llvm-{strip,objcopy}
+ --remove-build-id Remove the gnu build-id section in out-file
EOF
exit 1
}
@@ -63,6 +65,15 @@ do_strip() {
fi
}
+do_strip_keep_symbols_and_debug_frame() {
+ REMOVE_SECTIONS=`"${CROSS_COMPILE}readelf" -S "${infile}" | awk '/.debug_/ {if ($2 != ".debug_frame") {print "--remove-section " $2}}' | xargs`
+ if [ -z "${use_gnu_strip}" ]; then
+ "${CLANG_BIN}/llvm-objcopy" "${infile}" "${outfile}.tmp" ${REMOVE_SECTIONS}
+ else
+ "${CROSS_COMPILE}objcopy" "${infile}" "${outfile}.tmp" ${REMOVE_SECTIONS}
+ fi
+}
+
do_strip_keep_symbols() {
REMOVE_SECTIONS=`"${CROSS_COMPILE}readelf" -S "${infile}" | awk '/.debug_/ {print "--remove-section " $2}' | xargs`
if [ -z "${use_gnu_strip}" ]; then
@@ -148,6 +159,7 @@ while getopts $OPTSTRING opt; do
add-gnu-debuglink) add_gnu_debuglink=true ;;
keep-mini-debug-info) keep_mini_debug_info=true ;;
keep-symbols) keep_symbols=true ;;
+ keep-symbols-and-debug-frame) keep_symbols_and_debug_frame=true ;;
remove-build-id) remove_build_id=true ;;
use-gnu-strip) use_gnu_strip=true ;;
*) echo "Unknown option --${OPTARG}"; usage ;;
@@ -177,6 +189,16 @@ if [ ! -z "${keep_symbols}" -a ! -z "${keep_mini_debug_info}" ]; then
usage
fi
+if [ ! -z "${keep_symbols}" -a ! -z "${keep_symbols_and_debug_frame}" ]; then
+ echo "--keep-symbols and --keep-symbols-and-debug-frame cannot be used together"
+ usage
+fi
+
+if [ ! -z "${keep_mini_debug_info}" -a ! -z "${keep_symbols_and_debug_frame}" ]; then
+ echo "--keep-symbols-mini-debug-info and --keep-symbols-and-debug-frame cannot be used together"
+ usage
+fi
+
if [ ! -z "${symbols_to_keep}" -a ! -z "${keep_symbols}" ]; then
echo "--keep-symbols and -k cannot be used together"
usage
@@ -195,6 +217,8 @@ elif [ ! -z "${symbols_to_keep}" ]; then
do_strip_keep_symbol_list
elif [ ! -z "${keep_mini_debug_info}" ]; then
do_strip_keep_mini_debug_info
+elif [ ! -z "${keep_symbols_and_debug_frame}" ]; then
+ do_strip_keep_symbols_and_debug_frame
else
do_strip
fi