Skip to content

Commit 1417046

Browse files
committed
[JITLink] Include target addend in out-of-range error
When JITLink reports an out-of-range error, the underlying reason could be hidden from the user if it's due to an excessively large target addend. Add non-zero target addend to the message for clarity.
1 parent a2aa812 commit 1417046

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

llvm/lib/ExecutionEngine/JITLink/JITLink.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,10 @@ Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B,
427427
} else
428428
ErrStream << E.getTarget().getSection().getName() << " + "
429429
<< formatv("{0:x}", E.getOffset());
430-
ErrStream << " at address " << formatv("{0:x}", E.getTarget().getAddress())
431-
<< " is out of range of " << G.getEdgeKindName(E.getKind())
430+
ErrStream << " at address " << formatv("{0:x}", E.getTarget().getAddress());
431+
if (E.getAddend())
432+
ErrStream << " with addend " << formatv("{0:x}", E.getAddend());
433+
ErrStream << " is out of range of " << G.getEdgeKindName(E.getKind())
432434
<< " fixup at " << formatv("{0:x}", B.getFixupAddress(E)) << " (";
433435

434436
Symbol *BestSymbolForBlock = nullptr;

llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_SIZE.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# RUN: llvm-mc -triple=x86_64-unknown-linux -position-independent --defsym=OVERFLOW=1 \
88
# RUN: -filetype=obj -o %t.2.o %s
99
# RUN: not llvm-jitlink -noexec %t.2.o 2>&1 | FileCheck %s
10-
# CHECK: llvm-jitlink error: In graph {{.*}}, section .text: relocation target "main" at address {{.*}} is out of range of Size32 fixup at {{.*}} (main, {{.*}})
10+
# CHECK: llvm-jitlink error: In graph {{.*}}, section .text: relocation target "main" at address {{.*}} with addend {{.*}} is out of range of Size32 fixup at {{.*}} (main, {{.*}})
1111

1212
.text
1313
.globl main

0 commit comments

Comments
 (0)