When creating the compressed mini-symtab section in find-debuginfo add_minidebug we explicitly remove .gdb_index and .comment. But there can be other non-empty sections in the debuginfo that shouldn't be copied. For example rust binaries might have a .rustc section.
Explicitly remove any non-allocated PROGBITS or NOTE sections. https://bugzilla.redhat.com/show_bug.cgi?id=1382394 Signed-off-by: Mark Wielaard <[email protected]> --- scripts/find-debuginfo.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh index 5f6e0bb..1524ac2 100644 --- a/scripts/find-debuginfo.sh +++ b/scripts/find-debuginfo.sh @@ -193,6 +193,14 @@ add_minidebug() local keep_symbols=`mktemp` local mini_debuginfo=`mktemp` + # In the minisymtab we don't need the .debug_ sections (already removed + # by -S) but also not any other non-allocated PROGBITS or NOTE sections. + # List and remove them explicitly. We do want to keep the allocated, + # symbol and NOBITS sections so cannot use --keep-only because that is + # too agressive. Field $2 is the section name, $3 is the section type + # and $8 are the section flags. + local remove_sections=`readelf -W -S "$debuginfo" | awk '{ if (index($2,".debug_") != 1 && ($3 == "PROGBITS" || $3 == "NOTE") && index($8,"A") == 0) printf "--remove-section "$2" " }'` + # Extract the dynamic symbols from the main binary, there is no need to also have these # in the normal symbol table nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms" @@ -204,7 +212,7 @@ add_minidebug() # Keep all the function symbols not already in the dynamic symbol table comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols" # Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections - objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null + objcopy -S $remove_sections --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null #Inject the compressed data into the .gnu_debugdata section of the original binary xz "$mini_debuginfo" mini_debuginfo="${mini_debuginfo}.xz" -- 2.7.4 _______________________________________________ Rpm-maint mailing list [email protected] http://lists.rpm.org/mailman/listinfo/rpm-maint
