.eh_frame optimization question

Jie Zhang jzhang918@gmail.com
Wed Jan 3 10:06:00 GMT 2007


Sorry, there are a few words missing in my email. :-P

Jie Zhang wrote:
> On 1/3/07, Alan Modra <amodra@bigpond.net.au> wrote:
>>
>> > The currently
>> > issue is that if the whole .eh_frame section is removed, it does not
>> > get a chance to call _bfinfdpic_add_dyn_reloc for all of its
>> > relocations. Thus its dynamic relocations are not changed to R_*_NONE
>> > type.
>>
>> Hmm, but you alloc the reloc section contents with bfd_zalloc, don't
>> you?  So you shouldn't need to change anything.
>>
> Yes. it's true we don't change them explicitly to R_*_NONE. The tricky
                          ^ need to

> part of this bug of bfin port is the following assert which is at the
> beginning of elf32_bfinfdpic_finish_dynamic_sections.
> 
>      BFD_ASSERT (bfinfdpic_gotrel_section (info)->size
>           == (bfinfdpic_gotrel_section (info)->reloc_count
>               * sizeof (Elf32_External_Rel)));
> 
> bfinfdpic_gotrel_section (info)->size is calculated by
> bfinfdpic_check_relocs and bfinfdpic_gc_sweep_hook.
> bfinfdpic_check_relocs increments the counts of various types of
> relocations for each section of each bfd. bfinfdpic_gc_sweep_hook
> decrements the counts if some sections are garbage collected. These
> counts are used by size_dynamic_sections to calculate the size of
> gotrel section.
> 
> bfinfdpic_gotrel_section (info)->reloc_count is calculated in
> bfinfdpic_relocate_section. When _bfinfdpic_add_dyn_reloc is called
> for each dynamic relocation, reloc_count is incremented by 1.
> 
> 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!
> 
> My patch just make that assert happy in such situation. Removing that
> assert (and another check) also works, i.e. But I don't like to do so.
                                              ^ generates almost same 
object files.

> Keeping these checks will make debugging easier.
> 

Jie



More information about the Binutils mailing list