[PATCH] D27629: Fix unwind info relocation with large code model on AArch64

Yichao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 9 13:09:40 PST 2016


yuyichao created this revision.
yuyichao added a reviewer: t.p.northover.
yuyichao added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.

Makes sure that the unwind info uses 64bits pcrel relocation if a large code model is specified and handle the corresponding relocation in the ExecutionEngine. This can happen with certain kernel configuration (the same as the one in https://reviews.llvm.org/D27609, found at least on the ArchLinux stock kernel and the one used on https://www.packet.net/) using the builtin JIT memory manager.

The diff is on top of https://reviews.llvm.org/D27609 but they should be relatively independent.
Will add tests when I figure out how.


https://reviews.llvm.org/D27629

Files:
  lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
  lib/MC/MCObjectFileInfo.cpp


Index: lib/MC/MCObjectFileInfo.cpp
===================================================================
--- lib/MC/MCObjectFileInfo.cpp
+++ lib/MC/MCObjectFileInfo.cpp
@@ -279,6 +279,8 @@
   case Triple::mips64el:
     FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
     break;
+  case Triple::aarch64:
+  case Triple::aarch64_be:
   case Triple::x86_64:
     FDECFIEncoding = dwarf::DW_EH_PE_pcrel |
                      ((CMModel == CodeModel::Large) ? dwarf::DW_EH_PE_sdata8
Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
===================================================================
--- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -335,6 +335,13 @@
         static_cast<uint32_t>(Result & 0xffffffffU);
     break;
   }
+  case ELF::R_AARCH64_PREL64: {
+    uint64_t *TargetPtr =
+        reinterpret_cast<uint64_t *>(Section.getAddressWithOffset(Offset));
+    uint64_t Result = Value + Addend - FinalAddress;
+    support::ulittle64_t::ref{TargetPtr} = Result;
+    break;
+  }
   case ELF::R_AARCH64_CALL26: // fallthrough
   case ELF::R_AARCH64_JUMP26: {
     // Operation: S+A-P. Set Call or B immediate value to bits fff_fffc of the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27629.80941.patch
Type: text/x-patch
Size: 1219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161209/a417203a/attachment.bin>


More information about the llvm-commits mailing list