Bug 1991 - objcopy does not update sh_link correctly
Summary: objcopy does not update sh_link correctly
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: 2005-12-07 16:55 UTC by Andreas Schwab
Modified: 2005-12-31 22:04 UTC (History)
2 users (show)

See Also:
Host:
Target: ia64-*-*
Build:
Last reconfirmed:


Attachments
Test object (14.41 KB, application/octet-stream)
2005-12-07 16:57 UTC, Andreas Schwab
Details
Output of objcopy -g (5.03 KB, application/octet-stream)
2005-12-07 16:57 UTC, Andreas Schwab
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2005-12-07 16:55:55 UTC
When stripping sections from an ELF object (eg. with objcopy -g) the resulting 
object has invalid sh_link fields for LINK ORDER sections.
Comment 1 Andreas Schwab 2005-12-07 16:57:22 UTC
Created attachment 782 [details]
Test object
Comment 2 Andreas Schwab 2005-12-07 16:57:59 UTC
Created attachment 783 [details]
Output of objcopy -g
Comment 3 Andreas Schwab 2005-12-07 17:07:51 UTC
The problem is that elf_discarded_section points to the input section, but 
this is not the linker. 
Comment 4 H.J. Lu 2005-12-07 18:53:34 UTC
A patch is posted at

http://sourceware.org/ml/binutils/2005-12/msg00058.html

http://sourceware.org/ml/binutils/2005-12/msg00056.html

is similar. But it doesn't handle a section is removed by "-R".
Comment 5 Alan Modra 2005-12-08 06:23:01 UTC
A similar problem can be seen on older dynamic objects.  When stripping debug
sections, section syms for the removed sections are not removed from .dynsym,
because strip doesn't touch .dynsym.  This leaves symbols with invalid st_shndx
fields.  Dynamic objects created with newer binutils avoid the problem to some
extent by not emitting dynamic section syms for debug sections.
Comment 6 H.J. Lu 2005-12-31 22:04:24 UTC
I am closing this bug. If we really want to handle .dynsym in DSOs created
by old linker, we can open a new bug report.