Bug 3166 - --only-keep-debug doesn't work on .o files with group
Summary: --only-keep-debug doesn't work on .o files with group
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.17
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-01 08:13 UTC by Pawel Sikora
Modified: 2006-09-05 08:24 UTC (History)
3 users (show)

See Also:
Host:
Target: i486-linux
Build:
Last reconfirmed:


Attachments
compressed testcase. (100.57 KB, application/octet-stream)
2006-09-01 08:13 UTC, Pawel Sikora
Details
Do not treat group sections as debugging sections (481 bytes, patch)
2006-09-04 12:35 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2006-09-01 08:13:01 UTC
$ i486-gnu-linux-strip --only-keep-debug libau.a -o libau.a.debuginfo

BFD: BFD 2.17.50.0.3 20060715 internal error, aborting at elf.c line 2971
                              in bfd_elf_set_group_contents
BFD: Please report this bug.
Comment 1 Pawel Sikora 2006-09-01 08:13:40 UTC
Created attachment 1271 [details]
compressed testcase.
Comment 2 H.J. Lu 2006-09-02 00:55:17 UTC
Here is a simple testcase:

[hjl@gnu-13 strip-9]$ cat group.s
        .section .text,"axG",%progbits,foo_group,comdat
        .global foo
foo:
        .word 0
        .section .data,"awG",%progbits,foo_group,comdat
        .global bar
bar:
        .word 0
[hjl@gnu-13 strip-9]$ make
as   -o group.o group.s
./strip --only-keep-debug group.o -o xxx.o
BFD: BFD 2.17.50 20060823 internal error, aborting at
/export/gnu/src/binutils-import/binutils/bfd/elf.c line 2976 in
bfd_elf_set_group_contents

BFD: Please report this bug.

make: *** [xxx.o] Error 1

I will look into it.
Comment 3 H.J. Lu 2006-09-02 14:40:43 UTC
Nick, you added --only-keep-debug. Is --only-keep-debug supposed to work on .o
files? Can you look into it? Thanks.
Comment 4 Nick Clifton 2006-09-04 12:34:43 UTC
Hi Pawel, Hi H.J.

  The --only-keep-debug switch is not intended to work on object files (or
static libraries containing object files).  At least not those that contain
relocations that point into the debug sections (and which hence have incomplete
debugging information).

  This particular problem however appears to arise because strip thinks that the
group sections contain debugging information.  (The test for a debugging section
is basically one that contains information, but which is not allocated space in
the memory map at runtime).  The uploaded patch should resolve this.  Please
could you try it out and let me know if it works for you.

Cheers
  Nick
Comment 5 Nick Clifton 2006-09-04 12:35:30 UTC
Created attachment 1277 [details]
Do not treat group sections as debugging sections
Comment 6 Pawel Sikora 2006-09-04 13:02:11 UTC
(In reply to comment #4)
> The uploaded patch should resolve this.  Please
> could you try it out and let me know if it works for you.

it works for me. thank you very much.

ps).
i've filled one more bug about stripping debug from static libs -> PR3110 ;)
Comment 7 Pawel Sikora 2006-09-04 13:10:15 UTC
hmm, with this patch i get an error on shared libs.

i486-gnu-linux-objcopy --only-keep-debug \
  ../../build-stlport-release-i486-gnu-linux/libArmInstanceAdder.so \
  ../../build-stlport-release-i486-gnu-linux/libArmInstanceAdder.so.debuginfo

i486-gnu-linux-objcopy \
  --add-gnu-debuglink=../../build-stlport-release-i486-gnu-linux/libArmInstanceAdder.so.debuginfo
  ../../build-stlport-release-i486-gnu-linux/libArmInstanceAdder.so

i486-gnu-linux-objcopy: ../../build-stlport-release-i486-gnu-linux/libArmInstanceAdder.so.debuginfo: 
Invalid operation

can you confirm that?
Comment 8 Pawel Sikora 2006-09-04 13:19:12 UTC
please ignore last comment. my buildsystem was buggy :)
Comment 9 H.J. Lu 2006-09-04 16:30:03 UTC
If --only-keep-debug isn't supposed to be used on .o, we shouldn't try.

As for group, a group can contain a debug section. I will open a new bug. The
problem is when we strip a section, we don't ajust the section group when the
stripped section is a member of the section group.
Comment 10 Nick Clifton 2006-09-05 08:24:07 UTC
Hi Guys,

  I have checked in the patch, as well as an update to the documentation
specifiying that the --only-keep-debug switch is only intended to be used on
fully linked files.  (I could not see any reasonable way of enforcing this
restriction on the code however).

Cheers
  Nick
Comment 11 Sourceware Commits 2010-06-29 08:47:55 UTC
Subject: Bug 3166

CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2010-06-29 08:47:40

Modified files:
	binutils       : ChangeLog objcopy.c 

Log message:
	PR binutils/3166
	* objcopy.c (is_strip_section): Revert 2006-09-05.
	(setup_section): Make SHT_GROUP section nobits.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1655&r2=1.1656
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/objcopy.c.diff?cvsroot=src&r1=1.142&r2=1.143