[PATCH] D81184: [WIP][ELF][AArch64] Implement the logic for handling R_AARCH64_PLT32

Leonard Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 12:09:41 PDT 2020


leonardchan created this revision.
Herald added subscribers: llvm-commits, danielkiss, phosek, MaskRay, hiraditya, kristof.beyls, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: MaskRay.
Herald added a project: LLVM.
leonardchan planned changes to this revision.
leonardchan added reviewers: peter.smith, mcgrathr, phosek, pcc.
leonardchan removed subscribers: MaskRay, phosek.

This is the followup to D77647 <https://reviews.llvm.org/D77647> which implements handling for the new R_AARCH64_PLT32 relocation type. This relocation would benefit the PIC-friendly vtables feature described in D72959 <https://reviews.llvm.org/D72959>.

Copy/pasting details from D77647 <https://reviews.llvm.org/D77647>:

  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.

Some notable things In this patch:

- Choose PLT32 over PREL32 if the operand is a function or undefined. The PLT relocation should be relaxed appropriately during linking if it turns out the symbol is within the same linkage unit. We select PREL32 conservatively if we know the symbol is dso_local.
- Replace `aarch64-fpic-prel32.s` with `aarch64-fpic-plt32.s`. The original case in `aarch64-fpic-prel32.s` would've produced a PREL32 reloc and checked that a linker error was thrown for a bad relocation. This would no longer be the case since a PLT32 reloc is produced instead. `aarch64-fpic-plt32.s` uses the same code snippet but instead checks that the correct arithmetic is used.
- Update some tests that would use PREL32 to instead use PLT32.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81184

Files:
  lld/ELF/Arch/AArch64.cpp
  lld/ELF/InputSection.cpp
  lld/test/ELF/aarch64-fpic-plt32.s
  lld/test/ELF/aarch64-fpic-prel32.s
  lld/test/ELF/aarch64-plt32.s
  lld/test/ELF/aarch64-prel32.s
  lld/test/ELF/aarch64-undefined-weak.s
  llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
  llvm/test/MC/AArch64/arm32-elf-relocs.s
  llvm/test/MC/AArch64/arm64-elf-relocs.s
  llvm/test/MC/AArch64/elf-reloc-plt32.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81184.268548.patch
Type: text/x-patch
Size: 7876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200604/fd7c39dd/attachment.bin>


More information about the llvm-commits mailing list