Skip to content

Commit

Permalink
[JITLink][x86-64] Implement ELF::R_X86_64_16.
Browse files Browse the repository at this point in the history
We already had an x86_64::Pointer16 edge kind courtesy of Sunho's COFF/x86-64
work, it just needed to be wired up.
  • Loading branch information
lhames committed Apr 16, 2023
1 parent fe216d2 commit ad7ab8f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
case ELF::R_X86_64_32:
Kind = x86_64::Pointer32;
break;
case ELF::R_X86_64_16:
Kind = x86_64::Pointer16;
break;
case ELF::R_X86_64_32S:
Kind = x86_64::Pointer32Signed;
break;
Expand Down
33 changes: 33 additions & 0 deletions llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_16.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# RUN: llvm-mc -triple=x86_64-unknown-linux -position-independent \
# RUN: -filetype=obj -o %t.o %s
# RUN: llvm-jitlink -noexec -abs X=0x1234 -check=%s %t.o
# RUN: not llvm-jitlink -noexec -abs X=0x12345 %t.o 2>&1 | \
# RUN: FileCheck -check-prefix=CHECK-ERROR %s
#
# Check success and failure cases of R_X86_64_16 handling.

# jitlink-check: *{8}P = X

# CHECK-ERROR: relocation target "X" {{.*}} is out of range of Pointer16 fixup

.text
.section .text.main,"ax",@progbits
.globl main
.p2align 4, 0x90
.type main,@function
main:
xorl %eax, %eax
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main

.type P,@object
.data
.globl P
.p2align 1, 0x0
P:
.short X # Using short here generates R_X86_64_16.
.short 0
.short 0
.short 0
.size P, 8

0 comments on commit ad7ab8f

Please sign in to comment.