[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rpmorg-maint
Subject:    [Rpm-maint] [PATCH] find-debuginfo.sh: Don't copy extra sections into .gnu_debugdata.
From:       pmatilai () laiskiainen ! org (Panu Matilainen)
Date:       2016-10-10 12:21:38
Message-ID: ea488226-63c2-072d-4fa5-93238206abb9 () laiskiainen ! org
[Download RAW message or body]

On 10/07/2016 06:00 PM, Mark Wielaard wrote:
> 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 <mjw at redhat.com>
> ---
> 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"
> 

Applied, thanks!

	 - Panu -


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic