This is the mail archive of the
mailing list for the binutils project.
Re: ld: --gc-sections incompatible with --emit-relocs ?
- From: Nick Clifton <nickc at redhat dot com>
- To: David Lamy-Charrier <david dot lamy at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 12 Oct 2006 10:23:15 +0100
- Subject: Re: ld: --gc-sections incompatible with --emit-relocs ?
- References: <email@example.com>
After some tests, it appears that I also specify --emit-relocs on the
linker line, and removing this --emit-relocs causes --gc-sections to
work as expected.
Is any of you aware of such a limitation ?
Yes. The problem is that if relocations are being emitted, then the
linker cannot safely discard sections. This is because the linker does
not know why the relocations are being emitted, so it cannot tell if the
relocations associated with (potentially) garbage collected sections
should be emitted or not.
I did not find any reference in the manual.
True, this should be documented. I will fix that.
I would appreciate any hints on how to try to remove/workaround this
You would need to add extra code to the linker. Probably a new command
line switch to tell the linker to aggressively garbage collect sections.
You will need to make sure that any section that is removed in this
way also has any relocations associated with it removed from its
equivalent *.rel or *.rela section. (Or at least not emitted when the
other relocs are emitted).