diff options
| author | Maksim Panchenko <maks@fb.com> | 2015-11-08 19:34:17 +0000 |
|---|---|---|
| committer | Maksim Panchenko <maks@fb.com> | 2015-11-08 19:34:17 +0000 |
| commit | 87ef57148a83aa7013b7b1f86a586a3805a054ae (patch) | |
| tree | 849d636b11a59b6df9c0cff5c2d1be1498cc5f4b /llvm | |
| parent | a768624f143a3b75c7b65bf813398ae0f12d6c7b (diff) | |
| download | bcm5719-llvm-87ef57148a83aa7013b7b1f86a586a3805a054ae.tar.gz bcm5719-llvm-87ef57148a83aa7013b7b1f86a586a3805a054ae.zip | |
[RuntimeDyld] Add support for R_X86_64_PC8 relocation.
llvm-svn: 252423
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 8 | ||||
| -rw-r--r-- | llvm/test/ExecutionEngine/RuntimeDyld/X86/ELF_x64-64_PC8_relocations.s | 26 |
2 files changed, 34 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index de616232f21..99cec0edcd5 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -249,6 +249,14 @@ void RuntimeDyldELF::resolveX86_64Relocation(const SectionEntry &Section, << format("%p\n", Section.Address + Offset)); break; } + case ELF::R_X86_64_PC8: { + uint64_t FinalAddress = Section.LoadAddress + Offset; + int64_t RealOffset = Value + Addend - FinalAddress; + assert(isInt<8>(RealOffset)); + int8_t TruncOffset = (RealOffset & 0xFF); + Section.Address[Offset] = TruncOffset; + break; + } case ELF::R_X86_64_PC32: { uint64_t FinalAddress = Section.LoadAddress + Offset; int64_t RealOffset = Value + Addend - FinalAddress; diff --git a/llvm/test/ExecutionEngine/RuntimeDyld/X86/ELF_x64-64_PC8_relocations.s b/llvm/test/ExecutionEngine/RuntimeDyld/X86/ELF_x64-64_PC8_relocations.s new file mode 100644 index 00000000000..7df9225359f --- /dev/null +++ b/llvm/test/ExecutionEngine/RuntimeDyld/X86/ELF_x64-64_PC8_relocations.s @@ -0,0 +1,26 @@ +# RUN: llvm-mc -triple=x86_64-pc-linux -relocation-model=pic -filetype=obj -o %T/test_ELF_x86-64_PC8.o %s +# RUN: llvm-rtdyld -triple=x86_64-pc-linux -verify -map-section test_ELF_x86-64_PC8.o,.text.bar=0x10000 -map-section test_ELF_x86-64_PC8.o,.text.baz=0x10040 %T/test_ELF_x86-64_PC8.o +# RUN: llvm-rtdyld -triple=x86_64-pc-linux -verify -map-section test_ELF_x86-64_PC8.o,.text.baz=0x10000 -map-section test_ELF_x86-64_PC8.o,.text.bar=0x10040 %T/test_ELF_x86-64_PC8.o + +# Test that R_X86_64_PC8 relocation works. + + .section .text.bar,"ax" + .align 16, 0x90 + .type bar,@function +bar: + retq +.Ltmp1: + .size bar, .Ltmp1-bar + + .section .text.baz,"ax" + .align 16, 0x90 + .type baz,@function +baz: + movq %rdi, %rcx + jrcxz bar + retq +.Ltmp2: + .size baz, .Ltmp2-baz + + + .section ".note.GNU-stack","",@progbits |

