This is the mail archive of the binutils@sources.redhat.com 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]

REL vs. RELA: how to choose?


The following verbiage appears in the "Relocation" chapter of
EXECUTABLE AND LINKABLE FORMAT (ELF) Portable Formats Specification, Version 1.1:

------------------------------------------------------------------------------
As shown above, only Elf32_Rela entries contain an explicit
addend. Entries of type Elf32_Rel store an implicit addend in the
location to be modified. Depending on the processor architecture, one
form or the other might be necessary or more convenient. Consequently,
an implementation for a particular machine may use one form
exclusively or either form depending on context.
------------------------------------------------------------------------------

What are the processor-architecture features that might make one or
the other of REL vs. RELA necessary or more convenient?  This has been
a nagging question for some time now.  I have groped around with
google trying to find something more specific, but have thus-far
failed.  Levine's _Linkers & Loaders_ book doesn't have anything more
specific either.

With REL, Is the "implicit addend" referred to above those bits
assembled into the relocatable field of the insn?  E.g., assembler
stores `jmp 0x100', the text segment is linked at 0x2000, so after
relocation the insn becomes `jmp 0x2100'.  The target address is
computed as 0x2000+0x100, with 0x2000 coming from the start of the
.text segment, and the 0x100 coming from the contents of the jmp insn
field (the "implicit addend"?).  Is this correct, or am I confused?

How would the jmp insn in the previous example be assembled for RELA?
Would the assembler store `jmp 0', and put 0x100 into the r_addend
field of the relocation entry?  Is this correct, or am I confused?

Greg


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