[PATCH] Fix --gc-sections for MIPS.
David Daney
ddaney@avtrex.com
Thu Aug 4 00:04:00 GMT 2005
Alan Modra wrote:
> On Sat, Jul 30, 2005 at 10:43:48PM -0700, David Daney wrote:
>
>> * elflink.c (elf_gc_sweep): Set dynsymcount to correct value.
>
>
> OK.
>
Well I committed it.
But have now found that it was not sufficient. For C++ programs with
exception handling I was still getting the same assertion failures
because the dynsymcount was not correct. This new patch seems to fix
the assertion failure problem on mipsel-linux.
There is too much logic in _bfd_elf_link_renumber_dynsyms that would
have to be kept in sync with elf_gc_sweep_symbol in order to calculate a
consistent dynsymcount there.
The new patch just calls _bfd_elf_link_renumber_dynsyms to calculate the
value instead of trying to emulate its actions.
Although the link now succeeds with no errors, I am having problems at
runtime with undefined symbols. As far as I can tell they are caused by
functions being discarded that are referenced by exception handling
tables that are retained. It appears that there is code to handle this
that does "
/* Keep .gcc_except_table.* if the associated .text.* is
marked. This isn't very nice, but the proper solution,
splitting .eh_frame up and using comdat doesn't pan out
easily due to needing special relocs to handle the
difference of two symbols in separate sections.
Don't keep code sections referenced by .eh_frame. */
"
However I have not been able to generate objects that have
.gcc_except_table.* sections. They all seem to have a single
.gcc_except_table section that cannot be GCed.
This is using both gcc-3.4.4 and 4.1 from CVS today (both mipsel-linux
and i686-pc-linux-gnu). I am compiling like this:
g++ -ffunction-sections -fdata-sections -c l.cc
When I use objdump -h on the resulting l.o I get many .text.* sections
(one for each function), but only a single .gcc_except_table.
Q: Is anybody successfully using -ffunction-sections -fdata-sections
with --gc-sections and C++ programs?
Q: What compiler do you use?
In any event I think this patch is necessary.
As before, tested on i686-pc-linux-gnu hosted mipsel-linux cross with
make -k check. No regressions.
2005-08-00 David Daney <ddaney@avtrex.com>
* elflink.c (elf_gc_sweep): Add parameter output_bfd and call
_bfd_elf_link_renumber_dynsyms to count dynsyms.
(bfd_elf_gc_sections): Pass new arameter output_bfd to elf_gc_sweep.
OK to commit?
David Daney.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: b.d
URL: <https://sourceware.org/pipermail/binutils/attachments/20050804/f17cf31b/attachment.ksh>
More information about the Binutils
mailing list