summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-07-05 11:28:49 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-07-05 11:28:49 +0000
commitd0921a4696e097c54fa67f573718561dbdbd3103 (patch)
tree08caf3fa2f8d695e1eb9eb66cf78b185c5cf4481 /llvm/test/tools
parentfdef18b42d02d69ca3a7be9c8c38a83ace51d9ff (diff)
downloadbcm5719-llvm-d0921a4696e097c54fa67f573718561dbdbd3103.tar.gz
bcm5719-llvm-d0921a4696e097c54fa67f573718561dbdbd3103.zip
[Object/ELF.h] - Improve error reporting.
The errors coming from ELF.h are usually not very useful because they are uninformative. This patch is a first step to improve the situation. I tested this patch with a run of check-llvm and found that few messages are untested. In this patch, I did not add more tests but marked all such cases with a "TODO" comment. For all tested messages I extended the error text to provide more details (see test cases changed). Differential revision: https://reviews.llvm.org/D64014 llvm-svn: 365183
Diffstat (limited to 'llvm/test/tools')
-rw-r--r--llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test2
-rw-r--r--llvm/test/tools/llvm-objcopy/ELF/invalid-e_phoff.test8
-rw-r--r--llvm/test/tools/llvm-objcopy/ELF/invalid-e_shoff.test8
-rw-r--r--llvm/test/tools/llvm-readobj/elf-broken-dynsym-link.test2
-rw-r--r--llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test5
5 files changed, 15 insertions, 10 deletions
diff --git a/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test b/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test
index b8918b980e8..b9806e94fb9 100644
--- a/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test
+++ b/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test
@@ -47,4 +47,4 @@ ProgramHeaders:
Sections:
- Section: .dynamic
-# CHECK: Virtual address is not in any segment when locating .dynstr section contents
+# CHECK: virtual address is not in any segment: 0x260 when locating .dynstr section contents
diff --git a/llvm/test/tools/llvm-objcopy/ELF/invalid-e_phoff.test b/llvm/test/tools/llvm-objcopy/ELF/invalid-e_phoff.test
index 5efe2fc3829..f12b1bf318f 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/invalid-e_phoff.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/invalid-e_phoff.test
@@ -13,11 +13,13 @@
## Truncate the file to end before the program header table ends.
# RUN: %python -c "with open('%/t.o', 'r+b') as input: input.truncate(65)"
-# RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s
+# RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s --check-prefix=CASE1
+
+# CASE1: error: program headers are longer than binary of size 65: e_phoff = 0x40, e_phnum = 1, e_phentsize = 56
## Set the e_phoff field to a value much larger than the object file size.
# RUN: %python -c "with open('%/t2.o', 'r+b') as input: import struct; bytes = struct.pack('<Q', 0x40000000); input.seek(32); input.write(bytes)"
-# RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s
+# RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s --check-prefix=CASE2
--- !ELF
FileHeader:
@@ -28,4 +30,4 @@ FileHeader:
ProgramHeaders:
- Type: PT_LOAD
-# CHECK: error: program headers longer than binary
+# CASE2: error: program headers are longer than binary of size 120: e_phoff = 0x40000000, e_phnum = 1, e_phentsize = 56
diff --git a/llvm/test/tools/llvm-objcopy/ELF/invalid-e_shoff.test b/llvm/test/tools/llvm-objcopy/ELF/invalid-e_shoff.test
index 7eecde6b0ab..9ebfc11e3c7 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/invalid-e_shoff.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/invalid-e_shoff.test
@@ -11,11 +11,13 @@
## Truncate the file to end before the section header table ends.
# RUN: %python -c "with open('%/t.o', 'r+b') as input: input.truncate(65)"
-# RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s -DINPUT=%t.o
+# RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s -DINPUT=%t.o --check-prefix=CASE1
+
+# CASE1: error: '[[INPUT]]': section header table goes past the end of the file: e_shoff = 0x40
## Set the e_shoff field to a value much larger than the object file size.
# RUN: %python -c "with open('%/t2.o', 'r+b') as input: import struct; bytes = struct.pack('<Q', 0x40000000); input.seek(40); input.write(bytes)"
-# RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s -DINPUT=%t2.o
+# RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s -DINPUT=%t2.o --check-prefix=CASE2
--- !ELF
FileHeader:
@@ -27,4 +29,4 @@ Sections:
- Name: .foo
Type: SHT_PROGBITS
-# CHECK: error: '[[INPUT]]': section header table goes past the end of the file
+# CASE2: error: '[[INPUT]]': section header table goes past the end of the file: e_shoff = 0x40000000
diff --git a/llvm/test/tools/llvm-readobj/elf-broken-dynsym-link.test b/llvm/test/tools/llvm-readobj/elf-broken-dynsym-link.test
index 5aa993c9a4b..3c861287b5c 100644
--- a/llvm/test/tools/llvm-readobj/elf-broken-dynsym-link.test
+++ b/llvm/test/tools/llvm-readobj/elf-broken-dynsym-link.test
@@ -6,7 +6,7 @@
# RUN: llvm-readobj -S %t1 2>&1 | FileCheck %s --check-prefixes=LLVM,ERR
# RUN: llvm-readelf -S %t1 2>&1 | FileCheck %s --check-prefixes=GNU,ERR
-# ERR: warning: invalid sh_type for string table, expected SHT_STRTAB
+# ERR: warning: invalid sh_type for string table section [index 0]: expected SHT_STRTAB, but got SHT_NULL
# LLVM: Name: .dynsym
# LLVM-NEXT: Type: SHT_DYNSYM
diff --git a/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test b/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test
index a8302d37d82..b860aa4b3b5 100644
--- a/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test
+++ b/llvm/test/tools/llvm-readobj/elf-dynamic-malformed.test
@@ -141,7 +141,7 @@ ProgramHeaders:
# RUN: llvm-readobj --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck %s --check-prefix BAD-STRTAB-ERR
# RUN: llvm-readelf --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck %s --check-prefix BAD-STRTAB-ERR
-# BAD-STRTAB-ERR: warning: Unable to parse DT_STRTAB: Virtual address is not in any segment
+# BAD-STRTAB-ERR: warning: Unable to parse DT_STRTAB: virtual address is not in any segment: 0x2000000
# RUN: llvm-readobj --dynamic-table --needed-libs %t.bad-strtab | FileCheck %s --check-prefixes=BAD-STRTAB,BAD-STRTAB-LLVM
# RUN: llvm-readelf --dynamic-table --needed-libs %t.bad-strtab | FileCheck %s --check-prefixes=BAD-STRTAB,BAD-STRTAB-GNU
@@ -186,7 +186,8 @@ ProgramHeaders:
# RUN: llvm-readobj --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefixes=CHECK,BAD-RELA
# RUN: llvm-readelf --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefixes=CHECK,BAD-RELA-GNU
-# CHECK: warning: Unable to parse DT_RELA: Virtual address is not in any segment
+# CHECK: warning: Unable to parse DT_RELA: virtual address is not in any segment: 0x1000000
+
# BAD-RELA: DynamicSection [ (2 entries)
# BAD-RELA-NEXT: Tag Type Name/Value
# BAD-RELA-NEXT: 0x0000000000000007 RELA 0x1000000
OpenPOWER on IntegriCloud