summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Target.h19
-rw-r--r--lld/test/ELF/aarch64-abs16.s2
-rw-r--r--lld/test/ELF/aarch64-abs32.s2
-rw-r--r--lld/test/ELF/aarch64-ldprel-lo19-invalid.s2
-rw-r--r--lld/test/ELF/aarch64-prel16.s2
-rw-r--r--lld/test/ELF/aarch64-prel32.s2
-rw-r--r--lld/test/ELF/i386-reloc-16.s2
-rw-r--r--lld/test/ELF/i386-reloc-8.s2
-rw-r--r--lld/test/ELF/i386-reloc-range.s2
-rw-r--r--lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s2
-rw-r--r--lld/test/ELF/mips-out-of-bounds-call16-reloc.s2
-rw-r--r--lld/test/ELF/ppc64-addr16-error.s2
-rw-r--r--lld/test/ELF/x86-64-reloc-16.s2
-rw-r--r--lld/test/ELF/x86-64-reloc-8.s3
-rw-r--r--lld/test/ELF/x86-64-reloc-error.s4
-rw-r--r--lld/test/ELF/x86-64-reloc-range.s2
16 files changed, 30 insertions, 22 deletions
diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h
index 41716c71e4c..2902dbc9914 100644
--- a/lld/ELF/Target.h
+++ b/lld/ELF/Target.h
@@ -144,25 +144,32 @@ TargetInfo *getTarget();
template <class ELFT> bool isMipsPIC(const Defined *Sym);
+static inline void reportRangeError(uint8_t *Loc, RelType Type, const Twine &V,
+ int64_t Min, uint64_t Max) {
+ error(getErrorLocation(Loc) + "relocation " + lld::toString(Type) +
+ " out of range: " + V + " is not in [" + Twine(Min) + ", " +
+ Twine(Max) + "]");
+}
+
template <unsigned N>
static void checkInt(uint8_t *Loc, int64_t V, RelType Type) {
if (!llvm::isInt<N>(V))
- error(getErrorLocation(Loc) + "relocation " + lld::toString(Type) +
- " out of range");
+ reportRangeError(Loc, Type, Twine(V), llvm::minIntN(N), llvm::maxIntN(N));
}
template <unsigned N>
static void checkUInt(uint8_t *Loc, uint64_t V, RelType Type) {
if (!llvm::isUInt<N>(V))
- error(getErrorLocation(Loc) + "relocation " + lld::toString(Type) +
- " out of range");
+ reportRangeError(Loc, Type, Twine(V), 0, llvm::maxUIntN(N));
}
template <unsigned N>
static void checkIntUInt(uint8_t *Loc, uint64_t V, RelType Type) {
if (!llvm::isInt<N>(V) && !llvm::isUInt<N>(V))
- error(getErrorLocation(Loc) + "relocation " + lld::toString(Type) +
- " out of range");
+ // For the error message we should cast V to a signed integer so that error
+ // messages show a small negative value rather than an extremely large one
+ reportRangeError(Loc, Type, Twine((int64_t)V), llvm::minIntN(N),
+ llvm::maxUIntN(N));
}
template <unsigned N>
diff --git a/lld/test/ELF/aarch64-abs16.s b/lld/test/ELF/aarch64-abs16.s
index c4f5b3e44b5..20a65b1cf4a 100644
--- a/lld/test/ELF/aarch64-abs16.s
+++ b/lld/test/ELF/aarch64-abs16.s
@@ -24,4 +24,4 @@ _start:
// | FileCheck %s --check-prefix=OVERFLOW
// RUN: not ld.lld %t.o %t257.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
-// OVERFLOW: Relocation R_AARCH64_ABS16 out of range
+// OVERFLOW: Relocation R_AARCH64_ABS16 out of range: 65536 is not in [-32768, 65535]
diff --git a/lld/test/ELF/aarch64-abs32.s b/lld/test/ELF/aarch64-abs32.s
index b051692374b..b93f27a0bc4 100644
--- a/lld/test/ELF/aarch64-abs32.s
+++ b/lld/test/ELF/aarch64-abs32.s
@@ -24,4 +24,4 @@ _start:
// | FileCheck %s --check-prefix=OVERFLOW
// RUN: not ld.lld %t.o %t257.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
-// OVERFLOW: Relocation R_AARCH64_ABS32 out of range
+// OVERFLOW: Relocation R_AARCH64_ABS32 out of range: 4294967296 is not in [-2147483648, 4294967295]
diff --git a/lld/test/ELF/aarch64-ldprel-lo19-invalid.s b/lld/test/ELF/aarch64-ldprel-lo19-invalid.s
index 9552b99255f..04df32e0590 100644
--- a/lld/test/ELF/aarch64-ldprel-lo19-invalid.s
+++ b/lld/test/ELF/aarch64-ldprel-lo19-invalid.s
@@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %s -o %t.o
# RUN: not ld.lld -shared %t.o -o %t 2>&1 | FileCheck %s
-# CHECK: relocation R_AARCH64_LD_PREL_LO19 out of range
+# CHECK: relocation R_AARCH64_LD_PREL_LO19 out of range: 2065536 is not in [-1048576, 1048575]
ldr x8, patatino
.data
diff --git a/lld/test/ELF/aarch64-prel16.s b/lld/test/ELF/aarch64-prel16.s
index 4ae1f87e208..fc34f010853 100644
--- a/lld/test/ELF/aarch64-prel16.s
+++ b/lld/test/ELF/aarch64-prel16.s
@@ -28,4 +28,4 @@ _start:
// | FileCheck %s --check-prefix=OVERFLOW
// RUN: not ld.lld %t.o %t257.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
-// OVERFLOW: Relocation R_AARCH64_PREL16 out of range
+// OVERFLOW: Relocation R_AARCH64_PREL16 out of range: -94209 is not in [-32768, 65535]
diff --git a/lld/test/ELF/aarch64-prel32.s b/lld/test/ELF/aarch64-prel32.s
index 302f4521f46..7aa290382c5 100644
--- a/lld/test/ELF/aarch64-prel32.s
+++ b/lld/test/ELF/aarch64-prel32.s
@@ -28,4 +28,4 @@ _start:
// | FileCheck %s --check-prefix=OVERFLOW
// RUN: not ld.lld %t.o %t257.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
-// OVERFLOW: Relocation R_AARCH64_PREL32 out of range
+// OVERFLOW: Relocation R_AARCH64_PREL32 out of range: 18446744071562006527 is not in [-2147483648, 4294967295]
diff --git a/lld/test/ELF/i386-reloc-16.s b/lld/test/ELF/i386-reloc-16.s
index db9dc0b3690..d69e6fbc49a 100644
--- a/lld/test/ELF/i386-reloc-16.s
+++ b/lld/test/ELF/i386-reloc-16.s
@@ -9,6 +9,6 @@
// CHECK-NEXT: 200000 42
// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
-// ERROR: relocation R_386_16 out of range
+// ERROR: relocation R_386_16 out of range: 65536 is not in [0, 65535]
.short foo
diff --git a/lld/test/ELF/i386-reloc-8.s b/lld/test/ELF/i386-reloc-8.s
index b2e4426910e..c6ae67120e2 100644
--- a/lld/test/ELF/i386-reloc-8.s
+++ b/lld/test/ELF/i386-reloc-8.s
@@ -9,6 +9,6 @@
// CHECK-NEXT: 200000 42
// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
-// ERROR: relocation R_386_8 out of range
+// ERROR: relocation R_386_8 out of range: 256 is not in [0, 255]
.byte foo
diff --git a/lld/test/ELF/i386-reloc-range.s b/lld/test/ELF/i386-reloc-range.s
index 4fb5325e543..6f72f7af73c 100644
--- a/lld/test/ELF/i386-reloc-range.s
+++ b/lld/test/ELF/i386-reloc-range.s
@@ -16,7 +16,7 @@
// RUN: not ld.lld -Ttext 0x200 %t.o %t2.o -o %t2 2>&1 | FileCheck --check-prefix=ERR %s
-// ERR: {{.*}}:(.text+0x1): relocation R_386_PC16 out of range
+// ERR: {{.*}}:(.text+0x1): relocation R_386_PC16 out of range: 65536 is not in [-65536, 65535]
.global _start
_start:
diff --git a/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s b/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s
index 54c0cc74d39..817e458fa5e 100644
--- a/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s
+++ b/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s
@@ -12,7 +12,7 @@
# RUN: }" > %t.script
# RUN: not ld.lld %t.o -T %t.script -o %t 2>&1 | FileCheck %s
-# CHECK: error: {{.*}}:(.eh_frame+0x20): relocation R_X86_64_PC32 out of range
+# CHECK: error: {{.*}}:(.eh_frame+0x20): relocation R_X86_64_PC32 out of range: 64424443872 is not in [-2147483648, 2147483647]
.text
.globl _start
diff --git a/lld/test/ELF/mips-out-of-bounds-call16-reloc.s b/lld/test/ELF/mips-out-of-bounds-call16-reloc.s
index e5ac59c9530..64e9ab3aa7e 100644
--- a/lld/test/ELF/mips-out-of-bounds-call16-reloc.s
+++ b/lld/test/ELF/mips-out-of-bounds-call16-reloc.s
@@ -4,7 +4,7 @@
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t1.o
# RUN: not ld.lld %t1.o -o %t.exe 2>&1 | FileCheck %s
-# CHECK: relocation R_MIPS_CALL16 out of range
+# CHECK: relocation R_MIPS_CALL16 out of range: 32768 is not in [-32768, 32767]
.macro generate_values
.irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
diff --git a/lld/test/ELF/ppc64-addr16-error.s b/lld/test/ELF/ppc64-addr16-error.s
index 2bc8ef2ae4d..f16ca69957a 100644
--- a/lld/test/ELF/ppc64-addr16-error.s
+++ b/lld/test/ELF/ppc64-addr16-error.s
@@ -5,4 +5,4 @@
.short sym+65539
-// CHECK: relocation R_PPC64_ADDR16 out of range
+// CHECK: relocation R_PPC64_ADDR16 out of range: 65539 is not in [-32768, 32767]
diff --git a/lld/test/ELF/x86-64-reloc-16.s b/lld/test/ELF/x86-64-reloc-16.s
index 2954d9900cf..4822ec71757 100644
--- a/lld/test/ELF/x86-64-reloc-16.s
+++ b/lld/test/ELF/x86-64-reloc-16.s
@@ -9,6 +9,6 @@
// CHECK-NEXT: 200000 42
// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
-// ERROR: relocation R_X86_64_16 out of range
+// ERROR: relocation R_X86_64_16 out of range: 65536 is not in [0, 65535]
.short foo
diff --git a/lld/test/ELF/x86-64-reloc-8.s b/lld/test/ELF/x86-64-reloc-8.s
index 1c3831fafa2..df9a5e335f4 100644
--- a/lld/test/ELF/x86-64-reloc-8.s
+++ b/lld/test/ELF/x86-64-reloc-8.s
@@ -9,6 +9,7 @@
// CHECK-NEXT: 200000 42
// RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s
-// ERROR: relocation R_X86_64_8 out of range
+// ERROR: relocation R_X86_64_8 out of range: 256 is not in [0, 255]
+// ERROR: relocation R_X86_64_8 out of range: 256 is not in [0, 255]
.byte foo
diff --git a/lld/test/ELF/x86-64-reloc-error.s b/lld/test/ELF/x86-64-reloc-error.s
index ece1bd45aa4..cb600d9bf1e 100644
--- a/lld/test/ELF/x86-64-reloc-error.s
+++ b/lld/test/ELF/x86-64-reloc-error.s
@@ -6,5 +6,5 @@
movl $big, %edx
movq $foo - 0x1000000000000, %rdx
-# CHECK: {{.*}}:(.text+0x1): relocation R_X86_64_32 out of range
-# CHECK: {{.*}}:(.text+0x8): relocation R_X86_64_32S out of range
+# CHECK: {{.*}}:(.text+0x1): relocation R_X86_64_32 out of range: 68719476736 is not in [0, 4294967295]
+# CHECK: {{.*}}:(.text+0x8): relocation R_X86_64_32S out of range: -281474976710656 is not in [-2147483648, 2147483647]
diff --git a/lld/test/ELF/x86-64-reloc-range.s b/lld/test/ELF/x86-64-reloc-range.s
index 08f604ee6a3..2913458ab5c 100644
--- a/lld/test/ELF/x86-64-reloc-range.s
+++ b/lld/test/ELF/x86-64-reloc-range.s
@@ -1,7 +1,7 @@
// RUN: llvm-mc %s -o %t.o -triple x86_64-pc-linux -filetype=obj
// RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s
-// CHECK: {{.*}}:(.text+0x3): relocation R_X86_64_PC32 out of range
+// CHECK: {{.*}}:(.text+0x3): relocation R_X86_64_PC32 out of range: 2147483648 is not in [-2147483648, 2147483647]
// CHECK-NOT: relocation
lea foo(%rip), %rax
OpenPOWER on IntegriCloud