[RFC] [gold] Simplify relocation strategy logic

Richard Sandiford rdsandiford@googlemail.com
Tue Mar 15 09:06:00 GMT 2011


Cary Coutant <ccoutant@google.com> writes:
>> The case where Symbol::needs_dynamic_reloc() _does_ need to describe
>> the GOT entry itself is for the current definition of use_plt_offset().
>> That function is called for all relocations (including GOT relocations)
>> at the beginning of the target's relocate() function.  In the case of
>> GOT relocs, use_plt_offset() says whether the _GOT entry_ should be
>> redirected to the PLT.  (This is of course sometimes true for ifuncs,
>> but should never be true otherwise.)  So I claim that, in the context
>> of use_plt_offset(), needs_dynamic_reloc() really is telling you about
>> the GOT entry rather than the GOT reloc itself.
>
> We never call Symbol::use_plt_offset() when relocating a GOT entry. I
> think you're confusing that with the use_plt_offset_ flag in the
> Got_entry.

No.  What I meant was: we call Symbol::use_plt_offset() for all GOT
_relocations_.  At that stage, we're trying to work out what value the
relocation symbol resolves to, and in the case of GOT relocations,
that symbol value is the value that should be stored in the GOT _entry_.
The relocation-specific handling will then convert that (modified)
symbol value into a GOT offset.

So when we call Symbol::use_plt_offset() for GOT _relocations_,
it is effectively telling us whether the GOT _entry_ should be
directed to the PLT.    Symbol::use_plt_offset() calls
Symbol::needs_dynamic_reloc(), so in this case,
Symbol::needs_dynamic_reloc() is also telling us about the GOT entry.

Richard



More information about the Binutils mailing list