Decompress debug sections when creating debug info
`create_minidebuginfo` can fail when processing objects with compressed
debuginfo. To work around this we can use `llvm-objcopy` to decompress
the debug sections prior to processing.
Issue: FP3-A13#318
Test: m
Bug: 305277519
Bug: 346585375
(cherry picked from https://android-review.googlesource.com/q/commit:eba99f4ab14dc1f94d39e2e55127106be6f6a9f4)
(cherry picked from https://android-review.googlesource.com/q/commit:ec5b0473fbb04764352e192013454cda4ccfbc4b)
Merged-In: Ia149a81f01b0be974f395732c713fb23d92ac22f
Change-Id: Ia149a81f01b0be974f395732c713fb23d92ac22f
(cherry picked from commit 19064a684899ab2a4bcf6334f225cdc37d30bdd9)
diff --git a/scripts/strip.sh b/scripts/strip.sh
index d09c187..71cb1c6 100755
--- a/scripts/strip.sh
+++ b/scripts/strip.sh
@@ -98,9 +98,17 @@
"${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