From cefdf238e9ca9df240c2dbc3df3ced3fa9338686 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Sun, 24 Apr 2016 01:36:37 +0000 Subject: [PATCH] [RuntimeDyldELF] Handle GOTPCRELX/REX_GOTPCRELX. llvm-svn: 267309 --- llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 6 +++++- llvm/test/ExecutionEngine/RuntimeDyld/X86/ELF-relaxed.s | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 llvm/test/ExecutionEngine/RuntimeDyld/X86/ELF-relaxed.s diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index 5dc1731bca83..c2b843e923ff 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -1708,7 +1708,9 @@ relocation_iterator RuntimeDyldELF::processRelocationRef( Value.Offset); addRelocationForSection(RE, Value.SectionID); } - } else if (RelType == ELF::R_X86_64_GOTPCREL) { + } else if (RelType == ELF::R_X86_64_GOTPCREL || + RelType == ELF::R_X86_64_GOTPCRELX || + RelType == ELF::R_X86_64_REX_GOTPCRELX) { uint64_t GOTOffset = allocateGOTEntries(SectionID, 1); resolveGOTOffsetRelocation(SectionID, Offset, GOTOffset + Addend); @@ -1869,6 +1871,8 @@ bool RuntimeDyldELF::relocationNeedsStub(const RelocationRef &R) const { case ELF::R_X86_64_GOTPCREL: + case ELF::R_X86_64_GOTPCRELX: + case ELF::R_X86_64_REX_GOTPCRELX: case ELF::R_X86_64_PC32: case ELF::R_X86_64_PC64: case ELF::R_X86_64_64: diff --git a/llvm/test/ExecutionEngine/RuntimeDyld/X86/ELF-relaxed.s b/llvm/test/ExecutionEngine/RuntimeDyld/X86/ELF-relaxed.s new file mode 100644 index 000000000000..c5a87946f329 --- /dev/null +++ b/llvm/test/ExecutionEngine/RuntimeDyld/X86/ELF-relaxed.s @@ -0,0 +1,8 @@ +# RUN: llvm-mc -triple=x86_64-pc-linux -relocation-model=pic -filetype=obj -o %T/file.o %p/Inputs/ELF_STT_FILE_GLOBAL.s +# RUN: llvm-mc -triple=x86_64-pc-linux -relax-relocations -relocation-model=pic -filetype=obj -o %T/relaxed.o %s +# RUN: llvm-rtdyld -triple=x86_64-pc-linux -verify %T/file.o %T/relaxed.o + +# Test that RTDyldELF does not crash with 'unimplemented relocation' + +_main: + movq foo.c@GOTPCREL(%rip), %rax