[PATCH] D20033: [RuntimeDyld] Support R_390_PC64 relocation type
Bryan Chan via llvm-commits
llvm-commits at lists.llvm.org
Fri May 6 14:18:56 PDT 2016
bryanpkc created this revision.
bryanpkc added a reviewer: uweigand.
bryanpkc added a subscriber: llvm-commits.
When the MCJIT generates ELF code, some DWARF data requires 64-bit PC-relative relocation (R_390_PC64). This patch adds support for R_390_PC64 relocation to RuntimeDyld::resolveSystemZRelocation, to avoid an assertion failure.
http://reviews.llvm.org/D20033
Files:
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
test/ExecutionEngine/RuntimeDyld/SystemZ/
test/ExecutionEngine/RuntimeDyld/SystemZ/Inputs/
test/ExecutionEngine/RuntimeDyld/SystemZ/Inputs/rtdyld-globals.ll
test/ExecutionEngine/RuntimeDyld/SystemZ/cfi-relo-pc64.s
Index: test/ExecutionEngine/RuntimeDyld/SystemZ/cfi-relo-pc64.s
===================================================================
--- /dev/null
+++ test/ExecutionEngine/RuntimeDyld/SystemZ/cfi-relo-pc64.s
@@ -0,0 +1,32 @@
+// Test that R_390_PC32 and R_390_PC64 relocations can be generated.
+// RUN: llvm-mc -triple s390x-linux-gnu -relocation-model=pic -filetype=obj %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+
+// Test that RuntimeDyld can fix up such relocations.
+// RUN: llvm-mc -triple s390x-linux-gnu -relocation-model=pic -filetype=obj %s -o %T/test-s390x-cfi-relo-pc64.o
+// RUN: llc -mtriple=s390x-linux-gnu -relocation-model=pic -filetype=obj %S/Inputs/rtdyld-globals.ll -o %T/test-s390x-rtdyld-globals.o
+// RUN: llvm-rtdyld -triple=s390x-linux-gnu -verify %T/test-s390x-cfi-relo-pc64.o %T/test-s390x-rtdyld-globals.o
+
+f1:
+ .cfi_startproc
+ .cfi_personality 0x9c, foo // DW_EH_PE_indirect|DW_EH_PE_pcrel|DW_EH_PE_sdata8 (0x9c)
+ lr %r0, %r0
+ .cfi_endproc
+
+// CHECK: Section {
+// CHECK: Index:
+// CHECK: Name: .rela.eh_frame
+// CHECK-NEXT: Type: SHT_RELA
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x0
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 48
+// CHECK-NEXT: Link:
+// CHECK-NEXT: Info:
+// CHECK-NEXT: AddressAlignment: 8
+// CHECK-NEXT: EntrySize: 24
+// CHECK-NEXT: Relocations [
+// CHECK-NEXT: 0x12 R_390_PC64 foo 0x0
+// CHECK-NEXT: 0x28 R_390_PC32 .text 0x0
+// CHECK-NEXT: ]
+// CHECK: }
Index: test/ExecutionEngine/RuntimeDyld/SystemZ/Inputs/rtdyld-globals.ll
===================================================================
--- /dev/null
+++ test/ExecutionEngine/RuntimeDyld/SystemZ/Inputs/rtdyld-globals.ll
@@ -0,0 +1 @@
+ at foo = global i8 0
Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
===================================================================
--- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -1066,6 +1066,11 @@
case ELF::R_390_64:
writeInt64BE(LocalAddress, Value + Addend);
break;
+ case ELF::R_390_PC64: {
+ int64_t Delta = (Value + Addend) - Section.getLoadAddressWithOffset(Offset);
+ writeInt64BE(LocalAddress, Delta);
+ break;
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20033.56462.patch
Type: text/x-patch
Size: 2340 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160506/0e579f02/attachment.bin>
More information about the llvm-commits
mailing list