This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Multiple relocation in ELF


On Mon, Jul 24, 2006 at 11:26:27AM -0700, Michael Eager wrote:
> Alan Modra wrote:
> >ELF can support multiple symbols in a relocation expression.  The trick
> >is to apply multiple suitably defined relocations to the one location.
> 
> Can you give an example of how this might be done?  I don't think that
> it is possible to apply two relocations to a single location in ELF.

Suppose you want to calculate 32-bit expressions of the form

  (sym1 + addend) * sym2

then use two relocs R_XYZ_ADDR32 and R_XYZ_MULT32 at the same location,
with the MULT32 reloc appearing after the ADDR32 one.
R_XYZ_ADDR32 operates as per usual ELF relocs, calculating sym + addend
and storing to the section contents.  R_XYZ_MULT32 is defined to read
the section contents and multiply that value by sym, then store the
result back to the section.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]