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

* [Bug tools/24809] eu-unstrip to drop SECTION symbols if section .note.gnu.gold-version present
  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 ` mark at klomp dot org
  2019-07-15 13:14 ` [Bug binutils/24809] objcopy to not add " vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mark at klomp dot org @ 2019-07-15 12:59 UTC (permalink / raw)
  To: elfutils-devel

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

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
I can replicate this if I use objcopy to produce the hello.debug and
hello.stripped binaries. But why don't you just use eu-strip?

Doing:
$ eu-strip -f hello.debug -o hello.stripped hello
$ eu-unstrip hello.stripped hello.debug -o hello.unstripped

Produces:
$ ls -la
-rwxrwxr-x. 1 mark mark 10416 Jul 15 14:50 hello
-rw-rw-r--. 1 mark mark    92 Jul 15 14:50 hello.c
-rwxrwxr-x. 1 mark mark  6840 Jul 15 14:52 hello.debug
-rwxrwxr-x. 1 mark mark  6488 Jul 15 14:52 hello.stripped
-rwxrwxr-x. 1 mark mark 10416 Jul 15 14:52 hello.unstripped

$ readelf -s hello.debug | grep -c SECTION
0
$ readelf -s hello.stripped | grep -c SECTION
0
$ readelf -s hello.unstripped | grep -c SECTION
0

Which seems much more reasonable than what objcopy does.

I am not sure eu-unstrip should remove extra stuff objcopy adds. It seems that
if the user created these bigger than necessary .debug and .stripped files,
then they wanted that for some reason. It seems unwise to second guess the
user.

If there is a bug, then I think it is simply a bug in objcopy, which can be
prevented by using eu-strip instead.

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

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

* [Bug binutils/24809] objcopy to not add SECTION symbols if section .note.gnu.gold-version present
  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 ` vries at gcc dot gnu.org
  2019-07-25 16:25 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2019-07-15 13:14 UTC (permalink / raw)
  To: elfutils-devel

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tools                       |binutils
            Version|unspecified                 |2.33 (HEAD)
            Product|elfutils                    |binutils
            Summary|eu-unstrip to drop SECTION  |objcopy to not add SECTION
                   |symbols if section          |symbols if section
                   |.note.gnu.gold-version      |.note.gnu.gold-version
                   |present                     |present

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Mark Wielaard from comment #1)
> I can replicate this if I use objcopy to produce the hello.debug and
> hello.stripped binaries. But why don't you just use eu-strip?
> 

I think the idea here is to have the tools from the two "products" to play nice
together.

> Doing:
> $ eu-strip -f hello.debug -o hello.stripped hello
> $ eu-unstrip hello.stripped hello.debug -o hello.unstripped
> 
> Produces:
> $ ls -la
> -rwxrwxr-x. 1 mark mark 10416 Jul 15 14:50 hello
> -rw-rw-r--. 1 mark mark    92 Jul 15 14:50 hello.c
> -rwxrwxr-x. 1 mark mark  6840 Jul 15 14:52 hello.debug
> -rwxrwxr-x. 1 mark mark  6488 Jul 15 14:52 hello.stripped
> -rwxrwxr-x. 1 mark mark 10416 Jul 15 14:52 hello.unstripped
> 
> $ readelf -s hello.debug | grep -c SECTION
> 0
> $ readelf -s hello.stripped | grep -c SECTION
> 0
> $ readelf -s hello.unstripped | grep -c SECTION
> 0
> 
> Which seems much more reasonable than what objcopy does.
> 

Right, I noticed that.

> I am not sure eu-unstrip should remove extra stuff objcopy adds. It seems
> that if the user created these bigger than necessary .debug and .stripped
> files, then they wanted that for some reason. It seems unwise to second
> guess the user.
> 
> If there is a bug, then I think it is simply a bug in objcopy, which can be
> prevented by using eu-strip instead.

OK, changing product to binutils.

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

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

* [Bug binutils/24809] objcopy to not add SECTION symbols if section .note.gnu.gold-version present
  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
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2019-07-25 16:25 UTC (permalink / raw)
  To: elfutils-devel

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

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=48467cb99b04c9d908ce2dd74422c9c3f322ccc3

commit 48467cb99b04c9d908ce2dd74422c9c3f322ccc3
Author: Tom de Vries <vries@gcc.gnu.org>
Date:   Thu Jul 25 17:24:22 2019 +0100

    Have readelf and objdump display the contents of the DWARF augmentation
data as a string, if it is printable.

        PR 24809
        * dwarf.c (display_debug_names): Display the contents of the
        augmentation string, if it is printable.

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

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

* [Bug binutils/24809] objcopy to not add SECTION symbols if section .note.gnu.gold-version present
  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
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: nickc at redhat dot com @ 2019-07-25 16:30 UTC (permalink / raw)
  To: elfutils-devel

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

Nick Clifton <nickc at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nickc at redhat dot com

--- Comment #4 from Nick Clifton <nickc at redhat dot com> ---
(In reply to cvs-commit@gcc.gnu.org from comment #3)
> The master branch has been updated by Nick Clifton <nickc@sourceware.org>:
> 
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> h=48467cb99b04c9d908ce2dd74422c9c3f322ccc3

Sorry - this is not a patch for this PR.  It was a patch submitted by a
different person called Tom, and I got confused.  Doh!

Nick

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

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

* [Bug binutils/24809] objcopy to not add SECTION symbols if section .note.gnu.gold-version present
  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
                   ` (3 preceding siblings ...)
  2019-07-25 16:30 ` nickc at redhat dot com
@ 2019-07-25 16:36 ` vries at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2019-07-25 16:36 UTC (permalink / raw)
  To: elfutils-devel

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

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Nick Clifton from comment #4)
> (In reply to cvs-commit@gcc.gnu.org from comment #3)
> > The master branch has been updated by Nick Clifton <nickc@sourceware.org>:
> > 
> > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> > h=48467cb99b04c9d908ce2dd74422c9c3f322ccc3
>  
> Sorry - this is not a patch for this PR.  It was a patch submitted by a
> different person called Tom, and I got confused.  Doh!

Ah I see, thanks for mentioning this.  I was confused there for a bit.

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