This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: Multiple relocation in ELF
- From: "Santosh" <santosh at acmet dot com>
- To: "'Michael Eager'" <eager at eagercon dot com>, "'Richard Earnshaw'" <rearnsha at arm dot com>
- Cc: <binutils at sourceware dot org>
- Date: Wed, 26 Jul 2006 11:54:31 +0530
- Subject: RE: Multiple relocation in ELF
- Reply-to: <santosh at acmet dot com>
> -----Original Message-----
> From: Michael Eager [mailto:eager@eagercon.com]
> Sent: Tuesday, July 25, 2006 6:22 PM
> To: Richard Earnshaw
> Cc: Santosh; binutils@sourceware.org
> Subject: Re: Multiple relocation in ELF
>
> Richard Earnshaw wrote:
> > On Mon, 2006-07-24 at 19:26, Michael Eager wrote:
> >> Alan Modra wrote:
> >>> On Mon, Jul 24, 2006 at 04:22:41PM +0530, Santosh wrote:
> >>>> ADDIU r2, RELOCATABLE_SYMBOL + RELOCATABLE_SYMBOL
> >>>>
> >>>> In ELF, we can emit relocation information for only one symbol
having
> >>>> its symbol index, offset and relocation value to apply. But when
I
> try
> >>>> to give more than one relocatable symbol, it cannot be
represented by
> >>>> ELF format.
> >>> ELF can support multiple symbols in a relocation expression. The
> trick
> >>> is to apply multiple suitably defined relocations to the one
location.
> >> Alan --
> >>
> >> 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.
> >>
> >> I can think of one way that this might work, but it's problematic:
> >>
> >> If the relocations are in REL format, the addend is saved in the
> >> object file. (If RELA is used, the addend is in the reloc entry.)
> >> In either case, it seems that the result value from the first
> >> relocation will computed and stored in the output, then overwritten
> >> by the computation of the second relocation. The only way that
> >> these two relocations could be composed is if REL format is used,
> >> and the result of the relocation overwrote the value in the *input*
> >> object file, so that the result value from the first relocation
> >> is used as the addend of the second.
> >>
> >> If this is the scheme, I don't think that this behavior is defined
> >> by the ELF spec.
> >
> > The ELF spec is pretty specific on this issue. It's known as a
composed
> > sequence
> >
> > - Multiple relocations on the same place must all be of the same
type
> > (all REL or all RELA).
> > - Composed relocations are processed in order in the table
> > - The initial addend for the first relocation in the sequence is
> > extracted as normal
> > - Subsequent relocations use the result of the previous relocation
> > calculation as the initial addend value.
> >
> > The result is only written back at the end of the composed sequence.
> >
> > Note, however, that since all relocations are machine specific the
rules
> > can be varied somewhat. In particular a relocation code can be
> > specified to terminate a sequence or to start a new one.
>
> Thanks. You're right -- it is specified in the ELF 4.1 draft.
>
Please provide the link for ELF 4.1 draft.
Thank you
I Santhosh