Skip to content

Commit

Permalink
[JITLink][ELF] Add support for ELF::R_X86_64_REX_GOTPCRELX relocation.
Browse files Browse the repository at this point in the history
No support for relaxation yet -- this will always use the GOT entry.
  • Loading branch information
lhames committed Oct 23, 2020
1 parent 6e574ab commit e2fceec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
Expand Up @@ -232,6 +232,7 @@ class ELFLinkGraphBuilder_x86_64 {
case ELF::R_X86_64_64:
return ELF_x86_64_Edges::ELFX86RelocationKind::Pointer64;
case ELF::R_X86_64_GOTPCREL:
case ELF::R_X86_64_REX_GOTPCRELX:
return ELF_x86_64_Edges::ELFX86RelocationKind::PCRel32GOTLoad;
}
return make_error<JITLinkError>("Unsupported x86-64 relocation:" +
Expand Down
19 changes: 16 additions & 3 deletions llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s
Expand Up @@ -39,12 +39,25 @@ test_gotpcrel:
.Lend_test_gotpcrel:
.size test_gotpcrel, .Lend_test_gotpcrel-test_gotpcrel

# Test REX_GOTPCRELX handling. We want to check both the offset to the GOT entry and its
# contents.
# jitlink-check: decode_operand(test_rex_gotpcrelx, 4) = \
# jitlink-check: got_addr(elf_reloc.o, named_data) - next_pc(test_rex_gotpcrelx)

.globl test_rex_gotpcrelx
.p2align 4, 0x90
.type test_rex_gotpcrelx,@function
test_rex_gotpcrelx:
movq named_data@GOTPCREL(%rip), %rax
.Lend_test_rex_gotpcrelx:
.size test_rex_gotpcrelx, .Lend_test_gotpcrel-test_rex_gotpcrelx

.type named_data,@object
.data
.p2align 2
.p2align 3
named_data:
.long 42
.size named_data, 4
.quad 42
.size named_data, 8

# Test BSS / zero-fill section handling.
# llvm-jitlink: *{4}bss_variable = 0
Expand Down

0 comments on commit e2fceec

Please sign in to comment.