aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2018-11-07 16:28:49 -0800
committerYi Kong <yikong@google.com>2019-02-04 18:20:28 +0800
commitb5c34d7f4076187195399f6e490ed9845b56aa51 (patch)
tree6e0967c7e0632f925e7d4c9dff137243d4d75bf7 /scripts
parent93c3f5368de394657b48360590f090719d01c2ec (diff)
downloadbuild_soong-b5c34d7f4076187195399f6e490ed9845b56aa51.tar.gz
build_soong-b5c34d7f4076187195399f6e490ed9845b56aa51.tar.bz2
build_soong-b5c34d7f4076187195399f6e490ed9845b56aa51.zip
Use llvm-{strip,objcopy} by default
... except for Darwin Mach-O, as it is not supported by llvm-strip. Test: m checkbuild Bug: 119221035 Change-Id: I021637b6dd3530bff1f563f2ec7c2168e1083b7e
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/strip.sh22
1 files changed, 10 insertions, 12 deletions
diff --git a/scripts/strip.sh b/scripts/strip.sh
index d826e57c..bedc527d 100755
--- a/scripts/strip.sh
+++ b/scripts/strip.sh
@@ -27,7 +27,7 @@
# --add-gnu-debuglink
# --keep-mini-debug-info
# --keep-symbols
-# --use-llvm-strip
+# --use-gnu-strip
set -o pipefail
@@ -40,12 +40,12 @@ 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-llvm-strip Use llvm-{strip,objcopy} instead of strip/objcopy
+ --use-gnu-strip Use strip/objcopy instead of llvm-{strip,objcopy}
EOF
exit 1
}
-# With --use-llvm-strip, GNU strip is replaced with llvm-strip to work around
+# Without --use-gnu-strip, GNU strip is replaced with llvm-strip to work around
# old GNU strip bug on lld output files, b/80093681.
# Similary, calls to objcopy are replaced with llvm-objcopy,
# with some exceptions.
@@ -53,7 +53,7 @@ EOF
do_strip() {
# ${CROSS_COMPILE}strip --strip-all does not strip .ARM.attributes,
# so we tell llvm-strip to keep it too.
- if [ ! -z "${use_llvm_strip}" ]; then
+ if [ -z "${use_gnu_strip}" ]; then
"${CLANG_BIN}/llvm-strip" --strip-all -keep-section=.ARM.attributes "${infile}" -o "${outfile}.tmp"
else
"${CROSS_COMPILE}strip" --strip-all "${infile}" -o "${outfile}.tmp"
@@ -61,10 +61,8 @@ do_strip() {
}
do_strip_keep_symbols() {
- # Maybe we should replace this objcopy with llvm-objcopy, but
- # we have not found a use case that is broken by objcopy yet.
REMOVE_SECTIONS=`"${CROSS_COMPILE}readelf" -S "${infile}" | awk '/.debug_/ {print "--remove-section " $2}' | xargs`
- if [ ! -z "${use_llvm_strip}" ]; then
+ if [ -z "${use_gnu_strip}" ]; then
"${CLANG_BIN}/llvm-objcopy" "${infile}" "${outfile}.tmp" ${REMOVE_SECTIONS}
else
"${CROSS_COMPILE}objcopy" "${infile}" "${outfile}.tmp" ${REMOVE_SECTIONS}
@@ -74,7 +72,7 @@ do_strip_keep_symbols() {
do_strip_keep_mini_debug_info() {
rm -f "${outfile}.dynsyms" "${outfile}.funcsyms" "${outfile}.keep_symbols" "${outfile}.debug" "${outfile}.mini_debuginfo" "${outfile}.mini_debuginfo.xz"
local fail=
- if [ ! -z "${use_llvm_strip}" ]; then
+ if [ -z "${use_gnu_strip}" ]; then
"${CLANG_BIN}/llvm-strip" --strip-all -keep-section=.ARM.attributes -remove-section=.comment "${infile}" -o "${outfile}.tmp" || fail=true
else
"${CROSS_COMPILE}strip" --strip-all -R .comment "${infile}" -o "${outfile}.tmp" || fail=true
@@ -93,7 +91,7 @@ do_strip_keep_mini_debug_info() {
"${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"
"${XZ}" "${outfile}.mini_debuginfo"
- if [ ! -z "${use_llvm_strip}" ]; then
+ if [ -z "${use_gnu_strip}" ]; then
"${CLANG_BIN}/llvm-objcopy" --add-section .gnu_debugdata="${outfile}.mini_debuginfo.xz" "${outfile}.tmp"
else
"${CROSS_COMPILE}objcopy" --add-section .gnu_debugdata="${outfile}.mini_debuginfo.xz" "${outfile}.tmp"
@@ -105,7 +103,7 @@ do_strip_keep_mini_debug_info() {
}
do_add_gnu_debuglink() {
- if [ ! -z "${use_llvm_strip}" ]; then
+ if [ -z "${use_gnu_strip}" ]; then
"${CLANG_BIN}/llvm-objcopy" --add-gnu-debuglink="${infile}" "${outfile}.tmp"
else
"${CROSS_COMPILE}objcopy" --add-gnu-debuglink="${infile}" "${outfile}.tmp"
@@ -122,7 +120,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 ;;
- use-llvm-strip) use_llvm_strip=true ;;
+ use-gnu-strip) use_gnu_strip=true ;;
*) echo "Unknown option --${OPTARG}"; usage ;;
esac;;
?) usage ;;
@@ -172,7 +170,7 @@ fi
rm -f "${outfile}"
mv "${outfile}.tmp" "${outfile}"
-if [ ! -z "${use_llvm_strip}" ]; then
+if [ -z "${use_gnu_strip}" ]; then
USED_STRIP_OBJCOPY="${CLANG_BIN}/llvm-strip ${CLANG_BIN}/llvm-objcopy"
else
USED_STRIP_OBJCOPY="${CROSS_COMPILE}strip"