[PATCH] D105214: [ARM] RELA relocations for 32bit ARM ignore the addend.

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 1 01:29:52 PDT 2021


peter.smith added a comment.

I've not seen SHT_RELA used for debug data before and I think all of the other LLVM tools assume SHT_REL. Are you planning to add SHT_RELA support to the other LLVM tools?



================
Comment at: llvm/lib/Object/RelocationResolver.cpp:314
 
 static uint64_t resolveARM(uint64_t Type, uint64_t Offset, uint64_t S,
+                           uint64_t LocData, int64_t Addend) {
----------------
MaskRay wrote:
> MaskRay wrote:
> > The code is written in the assumption that targets preferring RELA always have Addend while targets preferring REL always have LocData.
> > 
> > Are you trying to add RELA support to ARM? I think it is unpopular but maybe you have specific needs which are not specified.
> > 
> > No objection, but a comment is needed.
> I think adding LocData and Addend is wrong. When RELA is used, LocData (implicit addend) should be ignored.
Agreed. The ELF spec says in http://www.sco.com/developers/gabi/latest/ch4.reloc.html
"As specified previously, only Elf32_Rela and Elf64_Rela entries contain an explicit addend. Entries of type Elf32_Rel and Elf64_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."

"The typical application of an ELF relocation is to determine the referenced symbol value, extract the addend (either from the field to be relocated or from the addend field contained in the relocation record, as appropriate for the type of relocation record), apply the expression implied by the relocation type to the symbol and addend, extract the desired part of the expression result, and place it in the field to be relocated."


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105214/new/

https://reviews.llvm.org/D105214



More information about the llvm-commits mailing list