2019-06-27 13:31:43 +02:00
## Check that llvm-objdump reports an error when
## .shstrtab has an invalid type.
# RUN: yaml2obj %s --docnum=1 -o %t1
2019-08-14 13:10:11 +02:00
# RUN: not llvm-objdump -s %t1 2>&1 | FileCheck %s -DFILE=%t1 --check-prefix=INVALID-SHTYPE
2019-06-27 13:31:43 +02:00
2019-08-14 13:10:11 +02:00
# INVALID-SHTYPE: error: '[[FILE]]': invalid sh_type for string table section [index 1]: expected SHT_STRTAB, but got SHT_PROGBITS
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .shstrtab
Type: SHT_PROGBITS
## Check that llvm-objdump reports an error when
## .shstrtab has an invalid zero-size.
# RUN: yaml2obj %s --docnum=2 -o %t2
2019-08-14 13:10:11 +02:00
# RUN: not llvm-objdump -s %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=STRTAB-EMPTY
# STRTAB-EMPTY: error: '[[FILE]]': SHT_STRTAB string table section [index 1] is empty
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .shstrtab
Type: SHT_STRTAB
Size: 0
## Check that llvm-objdump reports an error when .shstrtab has an invalid
## size that goes past the end of the file.
# RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-size.elf 2>&1 \
2019-08-14 13:10:11 +02:00
# RUN: | FileCheck %s -DFILE=%p/Inputs/invalid-strtab-size.elf --check-prefix=INVALID-STRTAB-SIZE
2019-12-02 12:08:20 +01:00
# INVALID-STRTAB-SIZE: error: '[[FILE]]': section [index 1] has a sh_offset (0x70) + sh_size (0xffffff) that is greater than the file size (0x218)
2019-06-27 13:31:43 +02:00
## Check that llvm-dwarfdump reports an error during relocation resolution
## when instead of expected SHT_RELA section it locates a section of a different type.
# RUN: yaml2obj %s --docnum=3 -o %t3
# RUN: not llvm-dwarfdump -debug-line %t3 2>&1 | FileCheck --check-prefix=RELA %s
2019-07-05 13:28:49 +02:00
# RELA: LLVM ERROR: Section is not SHT_RELA
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .debug_line
Type: SHT_PROGBITS
## The exact content does not matter here. We can use any minimal valid debug section
## which is a target for relocation. The idea is to trigger the code that reads the
## relocation's addend during relocation resolution. It should fail if called on
## a non-SHT_RELA section.
Content: 380000000200210000000101FB0E0D00010101010000000100000100676C6F62616C2E63707000000000000009020000000000000000130237000101
- Name: .rela.debug_line
Type: SHT_REL
Info: .debug_line
Relocations:
- Offset: 0x000000000000002E
Type: R_X86_64_64
## Check that llvm-objdump reports an error when it tries to dump section names
## and .shstrtab is not null-terminated.
# RUN: yaml2obj %s --docnum=4 -o %t4
2019-08-14 13:10:11 +02:00
# RUN: not llvm-objdump -s %t4 2>&1 | FileCheck -DFILE=%t4 --check-prefix=SHSTRTAB-NON-TERM %s
# SHSTRTAB-NON-TERM: error: '[[FILE]]': SHT_STRTAB string table section [index 1] is non-null terminated
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .shstrtab
Type: SHT_STRTAB
Content: "11"
## Check that llvm-objdump reports an error when it tries to dump a symbol name and
## .strtab is not null-terminated.
# RUN: yaml2obj %s --docnum=5 -o %t5
# RUN: not llvm-objdump -syms %t5 2>&1 | FileCheck --check-prefix=NONULL %s
2019-07-05 13:28:49 +02:00
# NONULL: error: {{.*}}: SHT_STRTAB string table section [index 1] is non-null terminated
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .strtab
Type: SHT_STRTAB
Content: "11"
Symbols:
- Name: foo
## Check that llvm-readobj reports an error if .symtab has an invalid sh_entsize.
# RUN: yaml2obj %s --docnum=6 -o %t6
2019-08-09 12:53:12 +02:00
# RUN: not llvm-readobj --symbols %t6 2>&1 | FileCheck -DFILE=%t6 --check-prefix=INVALID-SYM-SIZE %s
2019-06-27 13:31:43 +02:00
2019-08-09 12:53:12 +02:00
# INVALID-SYM-SIZE: error: '[[FILE]]': section [index 1] has an invalid sh_entsize: 32
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
EntSize: 32
Symbols:
- Name: foo
2019-07-11 14:26:48 +02:00
## Check that llvm-readobj reports a warning if .dynsym has an invalid sh_entsize.
2019-06-27 13:31:43 +02:00
# RUN: yaml2obj %s --docnum=7 -o %t7
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# RUN: llvm-readobj --dyn-symbols %t7 2>&1 | FileCheck -DFILE=%t7 --check-prefix=INVALID-DYNSYM-SIZE %s
2019-06-27 13:31:43 +02:00
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# INVALID-DYNSYM-SIZE: warning: '[[FILE]]': invalid section size (48) or entity size (32)
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .dynsym
Type: SHT_DYNSYM
EntSize: 32
DynamicSymbols:
- Name: foo
## Check that llvm-readobj reports an error if .symtab has an invalid sh_link value,
## which is greater than number of sections.
# RUN: yaml2obj %s --docnum=8 -o %t8
2019-08-09 12:53:12 +02:00
# RUN: not llvm-readobj --symbols %t8 2>&1 | FileCheck -DFILE=%t8 --check-prefix=INVALID-SYMTAB-LINK %s
2019-06-27 13:31:43 +02:00
2019-08-09 12:53:12 +02:00
# INVALID-SYMTAB-LINK: error: '[[FILE]]': invalid section index: 255
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Link: 0xFF
## Check that llvm-readobj reports an error when trying to dump sections
## when the e_shentsize field is broken.
# RUN: yaml2obj %s --docnum=9 -o %t9
# RUN: not llvm-readobj -S %t9 2>&1 | FileCheck --check-prefix=INVALID-SH-ENTSIZE %s
2019-07-05 13:28:49 +02:00
# INVALID-SH-ENTSIZE: error: {{.*}}: invalid e_shentsize in ELF header: 1
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
SHEntSize: 1
## Check that llvm-readobj reports an error if .symtab has sh_size
## that is not a multiple of sh_entsize.
# RUN: yaml2obj %s --docnum=10 -o %t10
2019-08-09 12:53:12 +02:00
# RUN: not llvm-readobj --symbols %t10 2>&1 | FileCheck -DFILE=%t10 --check-prefix=INVALID-SYMTAB-SIZE %s
2019-06-27 13:31:43 +02:00
2019-08-09 12:53:12 +02:00
# INVALID-SYMTAB-SIZE: error: '[[FILE]]': section [index 1] has an invalid sh_size (1) which is not a multiple of its sh_entsize (24)
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab
Type: SHT_SYMTAB
Size: 1
## Test that llvm-readobj reports an error if SHT_SYMTAB_SHNDX section has
## invalid sh_size which should be:
## sizeof(.symtab_shndx) = (sizeof(.symtab) / entsize(.symtab)) * entsize(.symtab_shndx)
# RUN: yaml2obj %s --docnum=11 -o %t11
# RUN: not llvm-readobj --symbols %t11 2>&1 | FileCheck --check-prefix=INVALID-XINDEX-SIZE %s
2019-10-25 10:55:11 +02:00
# INVALID-XINDEX-SIZE: error: {{.*}}: SHT_SYMTAB_SHNDX has 2 entries, but the symbol table associated has 1
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .symtab_shndx
Type: SHT_SYMTAB_SHNDX
2019-08-08 11:49:05 +02:00
Entries: [ 0, 1 ]
2019-06-27 13:31:43 +02:00
Link: .symtab
2019-10-20 16:47:17 +02:00
Symbols: []
2019-06-27 13:31:43 +02:00
## Check that llvm-readobj reports an error if the e_phentsize field is broken.
# RUN: not llvm-readobj --program-headers %p/Inputs/invalid-e_shnum.elf 2>&1 | \
2019-08-09 12:53:12 +02:00
# RUN: FileCheck -DFILE=%p/Inputs/invalid-e_shnum.elf --check-prefix=INVALID-PH-ENTSIZE %s
2019-06-27 13:31:43 +02:00
2019-08-09 12:53:12 +02:00
# INVALID-PH-ENTSIZE: error: '[[FILE]]': invalid e_phentsize: 12336
2019-06-27 13:31:43 +02:00
2019-11-04 13:00:39 +01:00
## Check that llvm-readobj reports a warning when we have no SHT_SYMTAB_SHNDX section,
2019-06-27 13:31:43 +02:00
## but have a symbol referencing it.
2019-11-04 13:00:39 +01:00
# RUN: llvm-readobj --symbols %p/Inputs/invalid-ext-symtab-index.elf-x86-64 2>&1 | \
2019-08-09 12:53:12 +02:00
# RUN: FileCheck -DFILE=%p/Inputs/invalid-ext-symtab-index.elf-x86-64 --check-prefix=INVALID-EXT-SYMTAB-INDEX %s
2019-06-27 13:31:43 +02:00
2019-11-04 13:00:39 +01:00
# INVALID-EXT-SYMTAB-INDEX: warning: '[[FILE]]': extended symbol index (0) is past the end of the SHT_SYMTAB_SHNDX section of size 0
# INVALID-EXT-SYMTAB-INDEX: Section: Reserved (0xFFFF)
2019-06-27 13:31:43 +02:00
## Check that llvm-readobj reports an error if a relocation section
## has a broken sh_offset (past the end of the file).
2019-07-02 12:30:06 +02:00
# RUN: yaml2obj %s --docnum=12 -o %t12
2019-07-02 12:47:13 +02:00
# RUN: yaml2obj %s --docnum=13 -o %t13
2019-08-09 12:53:12 +02:00
# RUN: not llvm-readobj -r %t12 2>&1 | FileCheck -DFILE=%t12 --check-prefix=INVALID-RELOC-SH-OFFSET %s
# RUN: not llvm-readobj -r %t13 2>&1 | FileCheck -DFILE=%t13 --check-prefix=INVALID-RELOC-SH-OFFSET %s
2019-06-27 13:31:43 +02:00
2019-12-02 12:08:20 +01:00
# INVALID-RELOC-SH-OFFSET: error: '[[FILE]]': section [index 1] has a sh_offset (0x10000) + sh_size (0x0) that is greater than the file size (0x160)
2019-06-27 13:31:43 +02:00
2019-07-02 12:30:06 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .rel
Type: SHT_REL
ShOffset: 0x10000
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .rela
Type: SHT_RELA
ShOffset: 0x10000
2019-10-20 16:47:17 +02:00
## Check that llvm-objdump reports an error when we try to print symbols and
## .shstrtab has a broken sh_offset so large that sh_offset + sh_size overflows the platform address size type.
2019-06-27 13:31:43 +02:00
2019-07-02 12:30:06 +02:00
# RUN: yaml2obj %s --docnum=14 -o %t14
2019-08-09 12:53:12 +02:00
# RUN: not llvm-readobj --symbols %t14 2>&1 | FileCheck -DFILE=%t14 --check-prefix=INVALID-SECTION-SIZE2 %s
2019-06-27 13:31:43 +02:00
2019-11-18 14:07:35 +01:00
# INVALID-SECTION-SIZE2: error: '[[FILE]]': section [index 1] has a sh_offset (0xffffffff) + sh_size (0x1b) that cannot be represented
2019-06-27 13:31:43 +02:00
2019-07-02 12:30:06 +02:00
--- !ELF
FileHeader:
2019-12-02 12:08:20 +01:00
Class: ELFCLASS32
2019-07-02 12:30:06 +02:00
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .shstrtab
Type: SHT_STRTAB
ShOffset: 0xFFFFFFFF
2019-10-20 16:47:17 +02:00
Symbols: []
2019-07-02 12:30:06 +02:00
2019-06-27 13:31:43 +02:00
## Check that llvm-readobj reports an error when trying to dump sections
## when the e_shnum field is broken (is greater than the actual number of sections).
2019-07-02 12:30:06 +02:00
# RUN: yaml2obj %s --docnum=15 -o %t15
# RUN: not llvm-readobj -S %t15 2>&1 | FileCheck --check-prefix=INVALID-SECTION-NUM %s
2019-06-27 13:31:43 +02:00
2019-07-05 13:28:49 +02:00
# INVALID-SECTION-NUM: error: {{.*}}: section table goes past the end of file
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
SHNum: 0xFF
## Check that llvm-readobj reports an error if a relocation contains an
## incorrect (too large) symbol index.
2019-07-02 12:30:06 +02:00
# RUN: yaml2obj %s --docnum=16 -o %t16
2019-08-09 12:53:12 +02:00
# RUN: not llvm-readobj -r %t16 2>&1 | FileCheck -DFILE=%t16 --check-prefix=INVALID-REL-SYM %s
2019-06-27 13:31:43 +02:00
2019-09-05 16:25:57 +02:00
# INVALID-REL-SYM: error: '[[FILE]]': unable to access section [index 2] data at 0x18000040: offset goes past the end of file
2019-06-27 13:31:43 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .rela.text
Type: SHT_RELA
Info: 0
Relocations:
- Offset: 0x0
Type: R_X86_64_64
Symbol: 0xFFFFFF
2019-10-28 11:47:44 +01:00
Symbols: []
2019-06-27 13:31:43 +02:00
## Check llvm-readobj does not crash on a truncated ELF.
## Create a truncated ELF object with ELFCLASSNONE class using echo.
## 0x7f, 'E', 'L', 'F', ELFCLASS64(2), ELFDATA2LSB(1),
## EV_CURRENT(1), ELFOSABI_LINUX(3), <padding zero bytes>, ET_REL(1), EM_NONE(0)
# RUN: echo -e -n "\x7f\x45\x4c\x46\x02\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" > %t11
# RUN: not llvm-readobj -r %t11 2>&1 | FileCheck --check-prefix=INVALID-BUFFER %s
2019-07-05 13:28:49 +02:00
# INVALID-BUFFER: error: {{.*}}': invalid buffer: the size (18) is smaller than an ELF header (64)
2019-06-27 13:31:43 +02:00
# RUN: not llvm-readobj %p/Inputs/invalid-coff-header-too-small 2>&1 | FileCheck --check-prefix=COFF-HEADER %s
# COFF-HEADER: The file was not recognized as a valid object file
2019-07-02 14:58:37 +02:00
## Check that llvm-readobj reports an error if section name offset
## overflows the section name string table.
# RUN: yaml2obj %s --docnum=17 -o %t17
2019-08-08 09:17:35 +02:00
# RUN: not llvm-readobj --sections %t17 2>&1 | FileCheck -DFILE=%t17 --check-prefix=BROKEN-SECNAME %s
2019-07-02 14:58:37 +02:00
2019-08-08 09:17:35 +02:00
## BROKEN-SECNAME: error: '[[FILE]]': a section [index 1] has an invalid sh_name (0x1) offset which goes past the end of the section name string table
2019-07-02 14:58:37 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .shstrtab
Type: SHT_STRTAB
Size: 1
## Check that llvm-readobj reports an error if a section has a broken offset
## that goes past the end of the file.
# RUN: yaml2obj %s --docnum=18 -o %t18
# RUN: not llvm-readobj --sections --section-data %t18 2>&1 \
2019-08-09 12:53:12 +02:00
# RUN: | FileCheck -DFILE=%t18 --check-prefix=BROKEN-SECSHOFFSET %s
2019-07-02 14:58:37 +02:00
2019-12-02 12:08:20 +01:00
# BROKEN-SECSHOFFSET: error: '[[FILE]]': section [index 1] has a sh_offset (0xffff0000) + sh_size (0x0) that is greater than the file size (0x160)
2019-07-02 14:58:37 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS
ShOffset: 0xFFFF0000
## Check that llvm-readobj reports an error if symbol name
## offset goes past the end of the symbol string table.
# RUN: yaml2obj %s --docnum=19 -o %t19
2019-08-09 12:53:12 +02:00
# RUN: not llvm-readobj --symbols %t19 2>&1 | FileCheck -DFILE=%t19 --check-prefix=INVALID-SYM-NAME %s
2019-07-02 14:58:37 +02:00
2019-08-29 12:55:57 +02:00
# INVALID-SYM-NAME: error: '[[FILE]]': st_name (0x1) is past the end of the string table of size 0x1
2019-07-02 14:58:37 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .strtab
Type: SHT_STRTAB
Size: 1
Symbols:
- Name: foo
## Version index in .gnu.version overflows the version map.
## Check llvm-readobj reports it.
# RUN: yaml2obj %s --docnum=20 -o %t20
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# RUN: not llvm-readobj -dt %t20 2>&1 | FileCheck -DFILE=%t20 --check-prefix=INVALID-VERSION %s
2019-07-02 14:58:37 +02:00
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# INVALID-VERSION: error: '[[FILE]]': Invalid version entry
2019-07-02 14:58:37 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .gnu.version
Type: SHT_GNU_versym
Entries: [ 0xFF ]
DynamicSymbols:
- Name: foo
## ELF header contains e_phentsize field with a value != sizeof(Elf_Phdr).
## Check llvm-readobj reports it.
# RUN: not llvm-readobj -l %p/Inputs/corrupt-invalid-phentsize.elf.x86-64 2>&1 \
2019-08-09 12:53:12 +02:00
# RUN: | FileCheck -DFILE=%p/Inputs/corrupt-invalid-phentsize.elf.x86-64 --check-prefix=PHENTSIZE %s
2019-07-02 14:58:37 +02:00
2019-08-09 12:53:12 +02:00
# PHENTSIZE: error: '[[FILE]]': invalid e_phentsize: 57
2019-07-02 14:58:37 +02:00
## The dynamic table contains DT_STRTAB with a value that is not in any loadable segment.
## Check llvm-readobj reports it.
# RUN: yaml2obj %s --docnum=21 -o %t21
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# RUN: llvm-readobj --dynamic-table %t21 2>&1 | FileCheck -DFILE=%t21 --check-prefix=INVALID-DTSTRTAB %s
2019-07-02 14:58:37 +02:00
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# INVALID-DTSTRTAB: warning: '[[FILE]]': Unable to parse DT_STRTAB: virtual address is not in any segment: 0xffff0000
2019-07-02 14:58:37 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .dynamic
Type: SHT_DYNAMIC
Address: 0x1000
Entries:
- Tag: DT_STRTAB
Value: 0xFFFF0000
- Tag: DT_NULL
Value: 0x0
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0x1000
Sections:
- Section: .dynamic
2019-07-11 14:26:48 +02:00
## Check that llvm-readobj reports a warning when a dynamic relocation section
2019-07-02 14:58:37 +02:00
## has sh_entsize field with size != sizeof(Elf_Rela).
2019-07-11 14:26:48 +02:00
# RUN: llvm-readobj --dyn-relocations \
2019-07-02 14:58:37 +02:00
# RUN: %p/Inputs/corrupt-invalid-relocation-size.elf.x86-64 2>&1 \
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# RUN: | FileCheck -DFILE=%p/Inputs/corrupt-invalid-relocation-size.elf.x86-64 --check-prefix=RELOC-BROKEN-ENTSIZE %s
2019-07-02 14:58:37 +02:00
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# RELOC-BROKEN-ENTSIZE: warning: '[[FILE]]': invalid section size (24) or entity size (25)
2019-07-02 14:58:37 +02:00
2019-07-11 14:26:48 +02:00
## Check that llvm-readobj reports a warning when .dynamic section has an invalid
2019-07-02 14:58:37 +02:00
## size, which isn't a multiple of the dynamic entry size.
# RUN: yaml2obj %s --docnum=22 -o %t22
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# RUN: llvm-readobj --dyn-relocations %t22 2>&1 | FileCheck -DFILE=%t22 --check-prefix=DYN-TABLE-SIZE %s
2019-07-02 14:58:37 +02:00
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# DYN-TABLE-SIZE: warning: '[[FILE]]': invalid section size (1) or entity size (16)
2019-07-02 14:58:37 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .dynamic
Type: SHT_DYNAMIC
Content: "00"
## PT_DYNAMIC's p_offset field is so large that p_offset + p_filesz is larger
## than the object size. Check llvm-readobj reports it.
# RUN: yaml2obj %s --docnum=23 -o %t23
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# RUN: llvm-readobj --dyn-relocations %t23 2>&1 | FileCheck -DFILE=%t23 --check-prefix=DYN-TABLE-PHDR %s
2019-07-02 14:58:37 +02:00
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# DYN-TABLE-PHDR: warning: '[[FILE]]': PT_DYNAMIC segment offset + size exceeds the size of the file
2019-07-02 14:58:37 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .dynamic
Type: SHT_DYNAMIC
Entries:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_DYNAMIC
Offset: 0xffff0000
Sections:
- Section: .dynamic
## PT_DYNAMIC's p_filesz field is so large that p_offset + p_filesz is larger
## than the object size. Check llvm-readobj reports it.
# RUN: yaml2obj %s --docnum=24 -o %t24
2019-08-12 16:05:37 +02:00
# RUN: llvm-readobj --dyn-relocations %t24 2>&1 \
Recommit r369190 "[llvm-readobj/llvm-readelf] - Improve/cleanup the error reporting API."
Fix: Add a `consumeError` call removed by mistake to 'printStackSize',
this should fix the "Expected<T> must be checked before access or destruction." reported by following bot:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9743/steps/stage%201%20check/logs/stdio
Original commit message:
Currently we have the following functions for error reporting:
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
void reportError(Error Err, StringRef Input);
void reportWarning(Twine Msg);
void reportWarning(StringRef Input, Error Err);
void warn(llvm::Error Err);
void error(std::error_code EC);
Problems are: naming is inconsistent, arguments order is inconsistent,
some of the functions looks excessive.
After applying this patch we have:
void reportError(Error Err, StringRef Input);
void reportError(std::error_code EC, StringRef Input);
void reportWarning(Error Err, StringRef Input);
I'd be happy to remove reportError(std::error_code EC, StringRef Input) too, but it
is used by COFF heavily.
Test cases were updated, they show an improvement introduced.
Differential revision: https://reviews.llvm.org/D66286
llvm-svn: 369194
2019-08-17 18:07:18 +02:00
# RUN: | FileCheck -DFILE=%t24 --check-prefix=DYN-TABLE-PHDR %s
2019-07-02 14:58:37 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .dynamic
Type: SHT_DYNAMIC
Entries:
- Tag: DT_NULL
Value: 0
ProgramHeaders:
- Type: PT_DYNAMIC
FileSize: 0xffff0000
Sections:
- Section: .dynamic
2019-07-16 13:07:30 +02:00
# RUN: yaml2obj --docnum=25 %s -o %t25
# RUN: not obj2yaml 2>&1 %t25 | FileCheck %s -DFILE=%t25 --check-prefix=INVALID-SHSTRNDX
# INVALID-SHSTRNDX: Error reading file: [[FILE]]: section header string table index 255 does not exist
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
SHStrNdx: 0xFF
Sections:
- Name: .foo
Type: SHT_PROGBITS
2019-07-24 13:24:37 +02:00
## We report an error if the number of sections stored in sh_size
## is greater than UINT64_MAX / sizeof(Elf_Shdr) == 288230376151711743.
## Here we check that do not crash on a border value.
# RUN: yaml2obj --docnum=26 %s -o %t26
# RUN: not llvm-readobj -h %t26 2>&1 | FileCheck -DFILE=%t26 --check-prefix=INVALID-SEC-NUM1 %s
2019-10-20 16:47:17 +02:00
# INVALID-SEC-NUM1: error: '[[FILE]]': invalid section header table offset (e_shoff = 0x58) or invalid number of sections specified in the first section header's sh_size field (0x3ffffffffffffff)
2019-07-24 13:24:37 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
SHNum: 0x0
Sections:
- Type: SHT_NULL
Size: 288230376151711743
## See above, but now we test the UINT64_MAX / sizeof(Elf_Shdr) value.
## The error is slightly different in this case.
# RUN: yaml2obj --docnum=27 %s -o %t27
# RUN: not llvm-readobj -h %t27 2>&1 | FileCheck -DFILE=%t27 --check-prefix=INVALID-SEC-NUM2 %s
# INVALID-SEC-NUM2: error: '[[FILE]]': invalid number of sections specified in the NULL section's sh_size field (288230376151711744)
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
SHNum: 0x0
Sections:
- Type: SHT_NULL
Size: 288230376151711744
2019-09-06 11:23:17 +02:00
## Check the case when SHOff is too large. SHOff + sizeof(Elf_Shdr) overflows the uint64 type.
2019-07-24 13:24:37 +02:00
# RUN: yaml2obj --docnum=28 %s -o %t28
# RUN: not llvm-readobj -h %t28 2>&1 | FileCheck -DFILE=%t28 --check-prefix=INVALID-SEC-NUM3 %s
# INVALID-SEC-NUM3: error: '[[FILE]]': section header table goes past the end of the file: e_shoff = 0xffffffffffffffff
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
2019-09-06 11:23:17 +02:00
SHOff: 0xffffffffffffffff
2019-07-31 10:12:01 +02:00
## Check that llvm-objdump reports an error when it tries to dump a
## symbol name and .strtab is empty.
# RUN: yaml2obj %s --docnum=29 -o %t29
# RUN: not llvm-objdump -syms %t29 2>&1 | FileCheck -DFILE=%t29 --check-prefix=STRTAB-EMPTY2 %s
# STRTAB-EMPTY2: error: '[[FILE]]': SHT_STRTAB string table section [index 1] is empty
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .strtab
Type: SHT_STRTAB
Content: ""
Symbols:
- Name: foo
2019-08-05 15:54:35 +02:00
2019-12-03 10:54:36 +01:00
## Check that we report a warning if SHT_GNU_versym has invalid
2019-08-05 15:54:35 +02:00
## sh_entsize value (3 instead of 2) when trying to access the entries.
# RUN: yaml2obj %s --docnum=30 -o %t30
2019-12-03 10:54:36 +01:00
# RUN: llvm-readobj -V %t30 2>&1 | FileCheck -DFILE=%t30 --check-prefix=INVALID-VER-SHENTSIZE %s
2019-08-05 15:54:35 +02:00
2019-12-03 10:54:36 +01:00
# INVALID-VER-SHENTSIZE: warning: '[[FILE]]': cannot read content of SHT_GNU_versym section with index 1: section [index 1] has an invalid sh_entsize: 3
2019-08-05 15:54:35 +02:00
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
OSABI: ELFOSABI_FREEBSD
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .gnu.version
Type: SHT_GNU_versym
EntSize: 0x0000000000000003
Entries: [ ]
2019-12-03 10:54:36 +01:00
Link: .dynsym
2019-08-05 15:54:35 +02:00
## Needed to trigger creation of .dynsym.
DynamicSymbols:
- Name: foo
Binding: STB_GLOBAL
2019-08-07 11:29:42 +02:00
## Check the case when e_shstrndx == SHN_XINDEX, but null section's sh_link contains
## the index of a section header string table that is larger than the number of the sections.
# RUN: yaml2obj --docnum=31 %s -o %t31
# RUN: not llvm-objcopy %t31 2>&1 | FileCheck %s -DFILE=%t31 --check-prefix=INVALID-SHSTRTAB-INDEX
# INVALID-SHSTRTAB-INDEX: error: section header string table index 255 does not exist
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
## SHN_XINDEX == 0xffff.
SHStrNdx: 0xffff
Sections:
- Type: SHT_NULL
Link: 0xff