Skip to content

Commit ad7ab8f

Browse files
committed
[JITLink][x86-64] Implement ELF::R_X86_64_16.
We already had an x86_64::Pointer16 edge kind courtesy of Sunho's COFF/x86-64 work, it just needed to be wired up.
1 parent fe216d2 commit ad7ab8f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
159159
case ELF::R_X86_64_32:
160160
Kind = x86_64::Pointer32;
161161
break;
162+
case ELF::R_X86_64_16:
163+
Kind = x86_64::Pointer16;
164+
break;
162165
case ELF::R_X86_64_32S:
163166
Kind = x86_64::Pointer32Signed;
164167
break;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# RUN: llvm-mc -triple=x86_64-unknown-linux -position-independent \
2+
# RUN: -filetype=obj -o %t.o %s
3+
# RUN: llvm-jitlink -noexec -abs X=0x1234 -check=%s %t.o
4+
# RUN: not llvm-jitlink -noexec -abs X=0x12345 %t.o 2>&1 | \
5+
# RUN: FileCheck -check-prefix=CHECK-ERROR %s
6+
#
7+
# Check success and failure cases of R_X86_64_16 handling.
8+
9+
# jitlink-check: *{8}P = X
10+
11+
# CHECK-ERROR: relocation target "X" {{.*}} is out of range of Pointer16 fixup
12+
13+
.text
14+
.section .text.main,"ax",@progbits
15+
.globl main
16+
.p2align 4, 0x90
17+
.type main,@function
18+
main:
19+
xorl %eax, %eax
20+
retq
21+
.Lfunc_end0:
22+
.size main, .Lfunc_end0-main
23+
24+
.type P,@object
25+
.data
26+
.globl P
27+
.p2align 1, 0x0
28+
P:
29+
.short X # Using short here generates R_X86_64_16.
30+
.short 0
31+
.short 0
32+
.short 0
33+
.size P, 8

0 commit comments

Comments
 (0)