[Bug tools/24809] New: eu-unstrip to drop SECTION symbols if section .note.gnu.gold-version present

vries at gcc dot gnu.org sourceware-bugzilla@sourceware.org
Mon Jul 15 10:59:00 GMT 2019


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.


More information about the Elfutils-devel mailing list