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 <ldv@altlinux.org>.
This commit is contained in:
Виталий Чикунов 2020-08-23 00:00:21 +03:00
parent aba565d889
commit 8682814b04

View File

@ -60,6 +60,25 @@ done
timestamp=$(date --iso-8601=ns --reference="$f") timestamp=$(date --iso-8601=ns --reference="$f")
@RPMCONFIGDIR@/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -l .tmp/src.$$ "$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 if [ -n "$strip" ]; then
mkdir -p "${debugf%/*}" mkdir -p "${debugf%/*}"
LD_ORIGIN_PATH=/usr/bin eu-strip $strip --remove-comment -f "$debugf" "$f" LD_ORIGIN_PATH=/usr/bin eu-strip $strip --remove-comment -f "$debugf" "$f"