diff options
Diffstat (limited to 'scripts/strip.sh')
| -rwxr-xr-x | scripts/strip.sh | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/scripts/strip.sh b/scripts/strip.sh index d09c187b1..8d69f0d12 100755 --- a/scripts/strip.sh +++ b/scripts/strip.sh @@ -29,6 +29,7 @@ # --keep-symbols # --keep-symbols-and-debug-frame # --remove-build-id +# --windows set -o pipefail @@ -43,6 +44,7 @@ Options: --keep-symbols Keep symbols in out-file --keep-symbols-and-debug-frame Keep symbols and .debug_frame in out-file --remove-build-id Remove the gnu build-id section in out-file + --windows Input file is Windows DLL or executable EOF exit 1 } @@ -50,7 +52,11 @@ EOF do_strip() { # GNU strip --strip-all does not strip .ARM.attributes, # so we tell llvm-strip to keep it too. - "${CLANG_BIN}/llvm-strip" --strip-all --keep-section=.ARM.attributes "${infile}" -o "${outfile}.tmp" + local keep_section=--keep-section=.ARM.attributes + if [ -n "${windows}" ]; then + keep_section= + fi + "${CLANG_BIN}/llvm-strip" --strip-all ${keep_section} "${infile}" -o "${outfile}.tmp" } do_strip_keep_symbols_and_debug_frame() { @@ -98,9 +104,17 @@ do_strip_keep_mini_debug_info_linux() { "${CLANG_BIN}/llvm-strip" --strip-all --keep-section=.ARM.attributes --remove-section=.comment "${infile}" -o "${outfile}.tmp" || fail=true if [ -z $fail ]; then - "${CREATE_MINIDEBUGINFO}" "${infile}" "${outfile}.mini_debuginfo.xz" + # create_minidebuginfo has issues with compressed debug sections. Just + # decompress them for now using objcopy which understands compressed + # debug sections. + # b/306150780 tracks supporting this directly in create_minidebuginfo + decompressed="$(mktemp)" + "${CLANG_BIN}/llvm-objcopy" --decompress-debug-sections \ + "${infile}" "${decompressed}" + + "${CREATE_MINIDEBUGINFO}" "${decompressed}" "${outfile}.mini_debuginfo.xz" "${CLANG_BIN}/llvm-objcopy" --add-section .gnu_debugdata="${outfile}.mini_debuginfo.xz" "${outfile}.tmp" - rm -f "${outfile}.mini_debuginfo.xz" + rm -f "${outfile}.mini_debuginfo.xz" "${decompressed}" else cp -f "${infile}" "${outfile}.tmp" fi @@ -141,6 +155,7 @@ while getopts $OPTSTRING opt; do keep-symbols) keep_symbols=true ;; keep-symbols-and-debug-frame) keep_symbols_and_debug_frame=true ;; remove-build-id) remove_build_id=true ;; + windows) windows=true ;; *) echo "Unknown option --${OPTARG}"; usage ;; esac;; ?) usage ;; |