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.

Test: m
Bug: 305277519
Change-Id: I0b3c1f08dfbcb7f8ebea2607ed3e22d901e63ecd
This commit is contained in:
Eric Rahm 2023-10-17 18:47:24 +00:00
parent eecf47b14c
commit 6f4c50ea9d

View file

@ -98,9 +98,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="${infile}.decompressed"
"${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