public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug tools/24809] New: eu-unstrip to drop SECTION symbols if section .note.gnu.gold-version present
Date: Mon, 15 Jul 2019 10:59:00 -0000	[thread overview]
Message-ID: <bug-24809-10460@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=24809

            Bug ID: 24809
           Summary: eu-unstrip to drop SECTION symbols if section
                    .note.gnu.gold-version present
           Product: elfutils
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: tools
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Consider a hello world with debug info, linked using gold:
...
$ gcc hello.c -g -fuse-ld=gold -o hello
...

Now say we strip using objcopy, and then unstrip:
...
$ objcopy --only-keep-debug hello hello.debug
$ objcopy --strip-debug hello hello.stripped
$ eu-unstrip hello.stripped hello.debug -o hello.unstripped
...

Interestingly, the unstripped exec is larger than the original:
...
$ ls -la
-rwxr-xr-x  1 vries users 14104 15 jul 12:34 hello
-rwxr-xr-x  1 vries users 11528 15 jul 12:34 hello.debug
-rwxr-xr-x  1 vries users  8760 15 jul 12:34 hello.stripped
-rwxr-xr-x  1 vries users 14896 15 jul 12:34 hello.unstripped
...

Comparing section sizes, we get:
...
$ readelf -S -W hello | grep ']'| sed 's/\[ /[/' | egrep -v 'NULL|Name' | awk
'{print $2, $6}' > SIZE.1
$ readelf -S -W hello.unstripped | grep ']'| sed 's/\[ /[/' | egrep -v
'NULL|Name' | awk '{print $2, $6}' > SIZE.2
$ diff -u SIZE.1 SIZE.2
--- SIZE.1      2019-07-15 12:43:14.495608629 +0200
+++ SIZE.2      2019-07-15 12:43:07.743655249 +0200
@@ -35,6 +35,6 @@
 .debug_ranges 000080
 .debug_loc 00013e
 .note.gnu.gold-version 00001c
-.symtab 0003c0
-.strtab 000213
+.symtab 000720
+.strtab 0001cf
 .shstrtab 000190
...

That is, the .strtab section is slightly smaller, but the .symtab section
significantly larger.

The difference is because of the SECTION symbols, which ld normally adds, but
gold doesn't.  However, objcopy adds them nevertheless:
...
$ readelf -s hello | grep -c SECTION
0
$ readelf -s hello.debug | grep -c SECTION
37
$ readelf -s hello.stripped | grep -c SECTION
30
$ readelf -s hello.unstripped | grep -c SECTION
37
...

It would be good if eu-unstrip could recognize the fact that the exec was
produced using gold (there seems to be a section .note.gnu.gold-version) and
drop those symbols (and likewise, objcopy should probably do the same).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2019-07-15 10:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-15 10:59 vries at gcc dot gnu.org [this message]
2019-07-15 12:59 ` [Bug tools/24809] " mark at klomp dot org
2019-07-15 13:14 ` [Bug binutils/24809] objcopy to not add " vries at gcc dot gnu.org
2019-07-25 16:25 ` cvs-commit at gcc dot gnu.org
2019-07-25 16:30 ` nickc at redhat dot com
2019-07-25 16:36 ` vries at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-24809-10460@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).