From 8682814b04c131bef9167bffd9f5753b455239f3 Mon Sep 17 00:00:00 2001 From: Vitaly Chikunov Date: Sun, 23 Aug 2020 00:00:21 +0300 Subject: [PATCH] debuginfo: Try to uncompress if debugedit failed to extract sources list If debugedit failed to extract sources list, uncompress and try again. Then compress back. ps. Interesting relevant reading: https://blogs.oracle.com/solaris/elf_section_compression-v2 Spelling suggestions by Dmitry V. Levin . --- scripts/process-debuginfo.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/process-debuginfo.in b/scripts/process-debuginfo.in index 1d35a44..1e4a2a6 100755 --- a/scripts/process-debuginfo.in +++ b/scripts/process-debuginfo.in @@ -60,6 +60,25 @@ done timestamp=$(date --iso-8601=ns --reference="$f") @RPMCONFIGDIR@/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -l .tmp/src.$$ "$f" +if [ ! -s .tmp/src.$$ ]; then + # debugedit has failed to extract sources list, possibly + # due to ELF compression - uncompress and try again. + LD_ORIGIN_PATH=/usr/bin eu-readelf -S "$f" > .tmp/sections.$$ + if grep -q ' \.debug_info .* PROGBITS .*C' .tmp/sections.$$; then + # Have SHF_COMPRESSED flag. + zmode=zlib-gabi + elif grep -q ' \.zdebug_info .* PROGBITS ' .tmp/sections.$$; then + zmode=zlib-gnu + else + zmode= + fi + rm .tmp/sections.$$ + if [ -n "$zmode" ]; then + LD_ORIGIN_PATH=/usr/bin eu-elfcompress --type=none "$f" + @RPMCONFIGDIR@/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -l .tmp/src.$$ "$f" + LD_ORIGIN_PATH=/usr/bin eu-elfcompress --type=$zmode "$f" + fi +fi if [ -n "$strip" ]; then mkdir -p "${debugf%/*}" LD_ORIGIN_PATH=/usr/bin eu-strip $strip --remove-comment -f "$debugf" "$f"