This is an archive of the discontinued LLVM Phabricator instance.

[ELF][AArch64] Add R_AARCH64_PLT32 relocation type.
ClosedPublic

Authored by psmith on Apr 7 2020, 6:58 AM.

Details

Summary

The R_AARCH64_PLT32 relocation type will be documented in the next release of ELF for the 64-bit Arm Architecture. It is being added in draft state for the benefit of the position independent vtable feature D72959

R_AARCH64_PLT32 is very similar to R_AARCH64_PREL32. The intention is to provide a signed 32-bit integer representing an offset from the place to a function.

  • It relocates 32-bit data
  • The expression is S + A - P
  • The overflow check for the expression is -2^31 <= X < 2^31
  • The relocation generates Thunks/Veneers/Stubs and PLT entries as per R_AARCH64_CALL26
  • If the symbol S is an undefined weak the ABI draft does not define its value.

The ABI defines a code for ilp32 for completeness, I have added the code but have only added to the existing reloc-types-elf-aarch64.text as there is no ilp32 equivalent test case.

Diff Detail

Event Timeline

psmith created this revision.Apr 7 2020, 6:58 AM
mcgrathr accepted this revision.Apr 7 2020, 12:15 PM

Thanks!

This revision is now accepted and ready to land.Apr 7 2020, 12:15 PM
MaskRay accepted this revision.EditedApr 7 2020, 1:16 PM

Ah, did not notice the author :/

A dedicated address insignificant relocation type will be useful. https://sourceware.org/pipermail/binutils/2020-April/000424.html

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2020, 4:49 AM
pcc added inline comments.Jun 5 2020, 3:08 PM
llvm/include/llvm/BinaryFormat/ELFRelocs/AArch64.def
135

I assume this isn't the final value of the relocation type? The range [0x400, ...] is reserved for dynamic relocations; I would have expected this to be added in the range [0x100, 0x200) together with the other non-TLS static relocations.

mcgrathr added inline comments.Jun 5 2020, 4:38 PM
llvm/include/llvm/BinaryFormat/ELFRelocs/AArch64.def
135

The draft shared by peter.smith@arm.com says:

+    | ELF64 Code | ELF32 Code | Name              | Operation | Comment                                                                   |
+    | 1033       | 189        | R\_<CLS>\_PLT32   | S + A - P | Check that -2\ :sup:`31` <= X < 2\ :sup:`31` see call and jump relocations|

I don't think it has been finalized yet so if different values make more sense, please follow up with him and/or arm.eabi@arm.com where these additions were discussed (and please CC: me and @leonardchan on any such discussion).

pcc added inline comments.Jun 5 2020, 6:36 PM
llvm/include/llvm/BinaryFormat/ELFRelocs/AArch64.def
135

Thanks, I followed up on the arm.eabi thread that everyone should already be cc'd on.