public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug tools/24809] New: eu-unstrip to drop SECTION symbols if section .note.gnu.gold-version present
@ 2019-07-15 10:59 vries at gcc dot gnu.org
  2019-07-15 12:59 ` [Bug tools/24809] " mark at klomp dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2019-07-15 10:59 UTC (permalink / raw)
  To: elfutils-devel

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-25 16:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-15 10:59 [Bug tools/24809] New: eu-unstrip to drop SECTION symbols if section .note.gnu.gold-version present vries at gcc dot gnu.org
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

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).