[llvm] ad7ab8f - [JITLink][x86-64] Implement ELF::R_X86_64_16.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 15 19:00:26 PDT 2023
Author: Lang Hames
Date: 2023-04-16T02:00:16Z
New Revision: ad7ab8f46516a5a2d6ec529ff4ce12567712a79a
URL: https://github.com/llvm/llvm-project/commit/ad7ab8f46516a5a2d6ec529ff4ce12567712a79a
DIFF: https://github.com/llvm/llvm-project/commit/ad7ab8f46516a5a2d6ec529ff4ce12567712a79a.diff
LOG: [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.
Added:
llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_16.s
Modified:
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index fe9675b390230..692b1619db002 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -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;
diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_16.s b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_16.s
new file mode 100644
index 0000000000000..eff9ebbff2a04
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_16.s
@@ -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", at progbits
+ .globl main
+ .p2align 4, 0x90
+ .type main, at function
+main:
+ xorl %eax, %eax
+ retq
+.Lfunc_end0:
+ .size main, .Lfunc_end0-main
+
+ .type P, at 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
More information about the llvm-commits
mailing list