relative GOT relocs in gold

Cary Coutant
Fri Apr 4 21:16:00 GMT 2008

>  Otherwise, my initial suggestion is that perhaps we should add a way
>  to point GOT entries at relocations, or parts of a relocation, and add
>  a new GOT type for that and assosciated ->write() methods.
>  Then I could register the GOT entry with ->add_local_with_rela()
>  or similar, and tell it "and BTW, put there gsym->value() in
>  this relocation addend over here instead of the GOT slot."
>  Alternatively, we could have a target fixup pass that can walk over
>  the dynamic relocs, and for this case the sparc target would
>  transfer the GOT slot values into the associated R_SPARC_RELATIVE
>  reloc addends, and clear the GOT slot.

If I understand correctly, you just need to call got->add_constant()
to create the GOT entry without an attached symbol (so that its slot
is initialized to zero). Then, separately, you can attach the
R_SPARC_RELATIVE relocation to it with rela_dyn->add_local_relative().
Output_reloc::write() will put the symbol value into the addend field
when the relocation is created with add_local_relative().

Forgive me if I'm misunderstanding something.


More information about the Binutils mailing list