[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
Tue Dec 13 06:25:22 PST 2016


yuyichao updated this revision to Diff 81226.
yuyichao added a comment.

Use target endian for data relocation. This one actually depends on https://reviews.llvm.org/D27609 now....


https://reviews.llvm.org/D27629

Files:
  lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
  lib/MC/MCObjectFileInfo.cpp
  test/ExecutionEngine/RuntimeDyld/AArch64/ELF_ARM64_large-relocations.s


Index: test/ExecutionEngine/RuntimeDyld/AArch64/ELF_ARM64_large-relocations.s
===================================================================
--- /dev/null
+++ test/ExecutionEngine/RuntimeDyld/AArch64/ELF_ARM64_large-relocations.s
@@ -0,0 +1,17 @@
+# RUN: llvm-mc -triple=arm64-none-linux-gnu -code-model=large -filetype=obj -o %T/large_reloc.o %s
+# RUN: llvm-rtdyld -triple=arm64-none-linux-gnu -verify -map-section large_reloc.o,.eh_frame=0x10000 -map-section large_reloc.o,.text=0xffff000000000000 -check=%s %T/large_reloc.o
+
+        .text
+        .globl  g
+        .p2align        2
+        .type   g, at function
+g:
+        .cfi_startproc
+        mov      x0, xzr
+        ret
+        .Lfunc_end0:
+        .size   g, .Lfunc_end0-g
+        .cfi_endproc
+
+# Skip the CIE and load the 8 bytes PC begin pointer
+# rtdyld-check: *{8}(section_addr(large_reloc.o, .eh_frame) + (*{4}(section_addr(large_reloc.o, .eh_frame))) + 0xc) = g - (section_addr(large_reloc.o, .eh_frame) + (*{4}(section_addr(large_reloc.o, .eh_frame))) + 0xc)
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
@@ -360,6 +360,16 @@
         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;
+    if (isBE)
+      support::ubig64_t::ref{TargetPtr} = Result;
+    else
+      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.81226.patch
Type: text/x-patch
Size: 2342 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161213/bed9ecc0/attachment.bin>


More information about the llvm-commits mailing list