[PATCH] D83800: Support PC relative relocation on AArch64 and PPC64 in RelocationResolver

Yichao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 11:24:57 PDT 2020


yuyichao created this revision.
yuyichao added reviewers: mstorsjo, Hsiang-Kai.
Herald added subscribers: llvm-commits, danielkiss, hiraditya, kristof.beyls, aprantl.
Herald added a project: LLVM.

Ref https://github.com/JuliaLang/julia/issues/35460

When compiled with `--code-model=large --relocation-model=static`, LLVM emits PC relative relocations in the `.eh_frame` section. Loading it then causes a waring to be printed.

AFAICT, the actual relocation is not actually used by any existing tools which is why I'm not adding any test. This also seems to be the case for X86 ref https://reviews.llvm.org/D67779 . The only test done is confirming that this fixes the warning with `llvm-dwarfdump`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83800

Files:
  llvm/lib/Object/RelocationResolver.cpp


Index: llvm/lib/Object/RelocationResolver.cpp
===================================================================
--- llvm/lib/Object/RelocationResolver.cpp
+++ llvm/lib/Object/RelocationResolver.cpp
@@ -62,6 +62,8 @@
   switch (Type) {
   case ELF::R_AARCH64_ABS32:
   case ELF::R_AARCH64_ABS64:
+  case ELF::R_AARCH64_PREL32:
+  case ELF::R_AARCH64_PREL64:
     return true;
   default:
     return false;
@@ -74,6 +76,9 @@
     return (S + getELFAddend(R)) & 0xFFFFFFFF;
   case ELF::R_AARCH64_ABS64:
     return S + getELFAddend(R);
+  case ELF::R_AARCH64_PREL32:
+  case ELF::R_AARCH64_PREL64:
+    return S + getELFAddend(R) - R.getOffset();
   default:
     llvm_unreachable("Invalid relocation type");
   }
@@ -152,6 +157,8 @@
   switch (Type) {
   case ELF::R_PPC64_ADDR32:
   case ELF::R_PPC64_ADDR64:
+  case ELF::R_PPC64_REL32:
+  case ELF::R_PPC64_REL64:
     return true;
   default:
     return false;
@@ -164,6 +171,9 @@
     return (S + getELFAddend(R)) & 0xFFFFFFFF;
   case ELF::R_PPC64_ADDR64:
     return S + getELFAddend(R);
+  case ELF::R_PPC64_REL32:
+  case ELF::R_PPC64_REL64:
+    return S + getELFAddend(R) - R.getOffset();
   default:
     llvm_unreachable("Invalid relocation type");
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83800.277911.patch
Type: text/x-patch
Size: 1219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200714/8fdf4601/attachment.bin>


More information about the llvm-commits mailing list