.eh_frame optimization question
Jie Zhang
jzhang918@gmail.com
Thu Jan 4 03:08:00 GMT 2007
Alan Modra wrote:
> On Wed, Jan 03, 2007 at 05:55:09PM +0800, Jie Zhang wrote:
>> This assert assures both calculations are equal and catches nontrivial
>> bugs early.
>>
>> When come to this specific bug, the relocation of the
>> going-to-be-removed .eh_frame is counted in bfinfdpic_check_relocs.
>> Since it's not remove by garbage collection, it's count not
>> decremented by bfinfdpic_gc_sweep_hook. Then the .eh_frame is
>> optimized away since all its entries have been removed. Thus
>> bfinfdpic_relocate_section cannot see this .eh_frame section and it's
>> relocations are not counted. The assert bangs!
>
> Can you provide a testcase? I would have thought that
$ cat test.cpp #include <iostream>
int main () {return 0;}
$ bfin-uclinux-g++ -mfdpic -ffunction-sections -o test -Wl,--gc-sections
test.cpp
/home/jie/installs/bfin-41-217/lib/gcc/bfin-uclinux/4.1.1/../../../../bfin-uclinux/bin/ld:
BFD 2.17.50 20070103 assertion fail
/home/jie/sources-cvs/binutils/src/bfd/elf32-bfin.c:4216
/home/jie/installs/bfin-41-217/lib/gcc/bfin-uclinux/4.1.1/../../../../bfin-uclinux/bin/ld:
LINKER BUG: .rofixup section size mismatch
/home/jie/installs/bfin-41-217/lib/gcc/bfin-uclinux/4.1.1/../../../../bfin-uclinux/bin/ld:
final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
I use latest CVS binutils and GCC 4.1 from blackfin.uclinux.org. But I
think GCC 4.1 from FSF repository will also produce the same issue.
> relocate_section would be called even though SEC_EXCLUDE is set, since
> presumably SEC_RELOC is also set for the input section. I must be
> missing something..
>
Before checking if SEC_RELOC is set for each input section,
elf_link_input_bfd checks its linker_mark:
if (! o->linker_mark)
{
/* This section was omitted from the link. */
continue;
}
Section's linker_mark is set to TRUE only in bfd_elf_final_link when its
linker_order type is bfd_indirect_link_order. In build_link_order, only
the input sections which don't have SEC_EXCLUDE set will be assigned
type bfd_indirect_link_order for its linker_order. So for .eh_frame with
SEC_EXCLUDE, linker_mark is FALSE...
Jie
More information about the Binutils
mailing list