Skip to content
Permalink
Browse files

Revert r369190, r369192 ([llvm-readobj/llvm-readelf] - Improve/cleanu…

  • Loading branch information
GeorgiiR committed Aug 17, 2019
1 parent e9f2813 commit c35d4c900d209b57f8cf8fe9030ecda054488b71
@@ -135,9 +135,9 @@ Symbols:
## Check that llvm-readobj reports a warning if .dynsym has an invalid sh_entsize.

# RUN: yaml2obj %s --docnum=7 -o %t7
# RUN: llvm-readobj --dyn-symbols %t7 2>&1 | FileCheck -DFILE=%t7 --check-prefix=INVALID-DYNSYM-SIZE %s
# RUN: llvm-readobj --dyn-symbols %t7 2>&1 | FileCheck --check-prefix=INVALID-DYNSYM-SIZE %s

# INVALID-DYNSYM-SIZE: warning: '[[FILE]]': invalid section size (48) or entity size (32)
# INVALID-DYNSYM-SIZE: warning: invalid section size (48) or entity size (32)

--- !ELF
FileHeader:
@@ -409,9 +409,9 @@ Symbols:
## Check llvm-readobj reports it.

# RUN: yaml2obj %s --docnum=20 -o %t20
# RUN: not llvm-readobj -dt %t20 2>&1 | FileCheck -DFILE=%t20 --check-prefix=INVALID-VERSION %s
# RUN: not llvm-readobj -dt %t20 2>&1 | FileCheck --check-prefix=INVALID-VERSION %s

# INVALID-VERSION: error: '[[FILE]]': Invalid version entry
# INVALID-VERSION: error: Invalid version entry

--- !ELF
FileHeader:
@@ -438,9 +438,9 @@ DynamicSymbols:
## Check llvm-readobj reports it.

# RUN: yaml2obj %s --docnum=21 -o %t21
# RUN: llvm-readobj --dynamic-table %t21 2>&1 | FileCheck -DFILE=%t21 --check-prefix=INVALID-DTSTRTAB %s
# RUN: llvm-readobj --dynamic-table %t21 2>&1 | FileCheck --check-prefix=INVALID-DTSTRTAB %s

# INVALID-DTSTRTAB: warning: '[[FILE]]': Unable to parse DT_STRTAB: virtual address is not in any segment: 0xffff0000
# INVALID-DTSTRTAB: warning: Unable to parse DT_STRTAB: virtual address is not in any segment: 0xffff0000

--- !ELF
FileHeader:
@@ -468,17 +468,17 @@ ProgramHeaders:

# RUN: llvm-readobj --dyn-relocations \
# RUN: %p/Inputs/corrupt-invalid-relocation-size.elf.x86-64 2>&1 \
# RUN: | FileCheck -DFILE=%p/Inputs/corrupt-invalid-relocation-size.elf.x86-64 --check-prefix=RELOC-BROKEN-ENTSIZE %s
# RUN: | FileCheck --check-prefix=RELOC-BROKEN-ENTSIZE %s

# RELOC-BROKEN-ENTSIZE: warning: '[[FILE]]': invalid section size (24) or entity size (25)
# RELOC-BROKEN-ENTSIZE: warning: invalid section size (24) or entity size (25)

## Check that llvm-readobj reports a warning when .dynamic section has an invalid
## size, which isn't a multiple of the dynamic entry size.

# RUN: yaml2obj %s --docnum=22 -o %t22
# RUN: llvm-readobj --dyn-relocations %t22 2>&1 | FileCheck -DFILE=%t22 --check-prefix=DYN-TABLE-SIZE %s
# RUN: llvm-readobj --dyn-relocations %t22 2>&1 | FileCheck --check-prefix=DYN-TABLE-SIZE %s

# DYN-TABLE-SIZE: warning: '[[FILE]]': invalid section size (1) or entity size (16)
# DYN-TABLE-SIZE: warning: invalid section size (1) or entity size (16)

--- !ELF
FileHeader:
@@ -495,9 +495,9 @@ Sections:
## than the object size. Check llvm-readobj reports it.

# RUN: yaml2obj %s --docnum=23 -o %t23
# RUN: llvm-readobj --dyn-relocations %t23 2>&1 | FileCheck -DFILE=%t23 --check-prefix=DYN-TABLE-PHDR %s
# RUN: llvm-readobj --dyn-relocations %t23 2>&1 | FileCheck --check-prefix=DYN-TABLE-PHDR %s

# DYN-TABLE-PHDR: warning: '[[FILE]]': PT_DYNAMIC segment offset + size exceeds the size of the file
# DYN-TABLE-PHDR: warning: PT_DYNAMIC segment offset + size exceeds the size of the file

--- !ELF
FileHeader:
@@ -522,7 +522,7 @@ ProgramHeaders:

# RUN: yaml2obj %s --docnum=24 -o %t24
# RUN: llvm-readobj --dyn-relocations %t24 2>&1 \
# RUN: | FileCheck -DFILE=%t24 --check-prefix=DYN-TABLE-PHDR %s
# RUN: | FileCheck --check-prefix=DYN-TABLE-PHDR %s

--- !ELF
FileHeader:
@@ -3,10 +3,10 @@

## Case 1: sh_link is set to 0.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj -S %t1 2>&1 | FileCheck %s -DFILE=%t1 --check-prefixes=LLVM,ERR
# RUN: llvm-readelf -S %t1 2>&1 | FileCheck %s -DFILE=%t1 --check-prefixes=GNU,ERR
# 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: '[[FILE]]': invalid sh_type for string table section [index 0]: expected SHT_STRTAB, but got SHT_NULL
# 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
@@ -36,10 +36,10 @@ Sections:
## Case 2: sh_link is set to 255, which is larger than the number of the sections.
# RUN: yaml2obj --docnum=2 %s -o %t2

# RUN: llvm-readobj -S %t2 2>&1 | FileCheck -DFILE=%t2 %s --check-prefixes=LLVM2,ERR2
# RUN: llvm-readelf -S %t2 2>&1 | FileCheck -DFILE=%t2 %s --check-prefixes=GNU2,ERR2
# RUN: llvm-readobj -S %t2 2>&1 | FileCheck %s --check-prefixes=LLVM2,ERR2
# RUN: llvm-readelf -S %t2 2>&1 | FileCheck %s --check-prefixes=GNU2,ERR2

# ERR2: warning: '[[FILE]]': invalid section index
# ERR2: warning: invalid section index

--- !ELF
FileHeader:
@@ -3,29 +3,29 @@

# RUN: yaml2obj %s --docnum=1 -o %t.bad-size
# RUN: llvm-readobj --all %t.bad-size 2>&1 \
# RUN: | FileCheck %s -DFILE=%t.bad-size --implicit-check-not=warning --check-prefix WARN
# RUN: | FileCheck %s --implicit-check-not=warning --check-prefix WARN
# RUN: llvm-readelf --all %t.bad-size 2>&1 \
# RUN: | FileCheck %s -DFILE=%t.bad-size --implicit-check-not=warning --check-prefix WARN-GNU
# RUN: | FileCheck %s --implicit-check-not=warning --check-prefix WARN-GNU

# WARN-NOT: warning
# WARN: warning: '[[FILE]]': invalid section size (4) or entity size (16)
# WARN: warning: invalid section size (4) or entity size (16)
# WARN-EMPTY:
# WARN-NEXT: File:
# WARN: Symbols [
# WARN: ]
# WARN-EMPTY:
## A warning is printed at the place where a normal dynamic table should be.
# WARN-NEXT: warning: '[[FILE]]': invalid section size (4) or entity size (16)
# WARN-NEXT: warning: invalid section size (4) or entity size (16)
# WARN-NEXT: ProgramHeaders [

# WARN-GNU-NOT: warning
# WARN-GNU: warning: '[[FILE]]': invalid section size (4) or entity size (16)
# WARN-GNU: warning: invalid section size (4) or entity size (16)
# WARN-GNU-NEXT: ELF Header:
# WARN-GNU: Symbol table '.symtab' contains 1 entries:
# WARN-GNU: 0:
# WARN-GNU-EMPTY:
## A warning is printed at the place where a normal dynamic table should be.
# WARN-GNU: warning: '[[FILE]]': invalid section size (4) or entity size (16)
# WARN-GNU: warning: invalid section size (4) or entity size (16)
# WARN-GNU-EMPTY:

--- !ELF
@@ -162,9 +162,9 @@ ProgramHeaders:
## Test handling of DT_STRTAB pointing outside the file's address space.
# RUN: yaml2obj %s --docnum=4 -o %t.bad-strtab

# RUN: llvm-readobj --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck -DFILE=%t.bad-strtab %s --check-prefix BAD-STRTAB-ERR
# RUN: llvm-readelf --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck -DFILE=%t.bad-strtab %s --check-prefix BAD-STRTAB-ERR
# BAD-STRTAB-ERR: warning: '[[FILE]]': Unable to parse DT_STRTAB: virtual address is not in any segment: 0x2000000
# 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: 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
@@ -206,10 +206,10 @@ ProgramHeaders:

## Test handling of other d_ptr tags pointing outside the file's address space.
# RUN: yaml2obj %s --docnum=5 -o %t.bad-rela
# RUN: llvm-readobj --dynamic-table %t.bad-rela 2>&1 | FileCheck -DFILE=%t.bad-rela %s --check-prefixes=CHECK,BAD-RELA
# RUN: llvm-readelf --dynamic-table %t.bad-rela 2>&1 | FileCheck -DFILE=%t.bad-rela %s --check-prefixes=CHECK,BAD-RELA-GNU
# 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: '[[FILE]]': Unable to parse DT_RELA: virtual address is not in any segment: 0x1000000
# 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
@@ -3,11 +3,11 @@

# RUN: yaml2obj %s -o %t.o
# RUN: llvm-readobj --dynamic-table %t.o 2>&1 \
# RUN: | FileCheck -DFILE=%t.o --check-prefixes=WARNING,LLVM %s
# RUN: | FileCheck --check-prefixes=WARNING,LLVM %s
# RUN: llvm-readelf --dynamic-table %t.o 2>&1 \
# RUN: | FileCheck -DFILE=%t.o --check-prefixes=WARNING,GNU %s
# RUN: | FileCheck --check-prefixes=WARNING,GNU %s

# WARNING: warning: '[[FILE]]': The SHT_DYNAMIC section '.dynamic' is not contained within the PT_DYNAMIC segment
# WARNING: warning: The SHT_DYNAMIC section '.dynamic' is not contained within the PT_DYNAMIC segment

# LLVM: DynamicSection [ (2 entries)
# LLVM-NEXT: Tag Type Name/Value
@@ -13,14 +13,14 @@
# within the file.
# RUN: cp %t.stripped %t.truncated1
# RUN: %python -c "with open(r'%t.truncated1', 'r+') as f: f.truncate(0x1001)"
# RUN: llvm-readobj %t.truncated1 --dynamic-table 2>&1 | FileCheck -DFILE=%t.truncated1 %s
# RUN: llvm-readobj %t.truncated1 --dynamic-table 2>&1 | FileCheck %s

# Test case where the offset is too large to be in the file.
# RUN: cp %t.stripped %t.truncated2
# RUN: %python -c "with open(r'%t.truncated2', 'r+') as f: f.truncate(0xFFF)"
# RUN: llvm-readobj %t.truncated2 --dynamic-table 2>&1 | FileCheck -DFILE=%t.truncated2 %s
# RUN: llvm-readobj %t.truncated2 --dynamic-table 2>&1 | FileCheck %s

# CHECK: warning: '[[FILE]]': PT_DYNAMIC segment offset + size exceeds the size of the file
# CHECK: warning: PT_DYNAMIC segment offset + size exceeds the size of the file

--- !ELF
FileHeader:
@@ -6,11 +6,11 @@

# RUN: yaml2obj --docnum=1 %s -o %t.o
# RUN: llvm-readobj --dynamic-table %t.o 2>&1 \
# RUN: | FileCheck %s --DFILE=%t.o --check-prefixes=WARNING,LLVM
# RUN: | FileCheck %s --check-prefixes=WARNING,LLVM
# RUN: llvm-readelf --dynamic-table %t.o 2>&1 \
# RUN: | FileCheck %s --DFILE=%t.o --check-prefixes=WARNING,GNU
# RUN: | FileCheck %s --check-prefixes=WARNING,GNU

# WARNING: warning: '[[FILE]]': The SHT_DYNAMIC section '.dynamic' is not at the start of PT_DYNAMIC segment
# WARNING: warning: The SHT_DYNAMIC section '.dynamic' is not at the start of PT_DYNAMIC segment

# LLVM: DynamicSection [ (2 entries)
# LLVM-NEXT: Tag Type Name/Value
@@ -24,12 +24,12 @@
# RUN: llvm-readobj -x 9 -x 9 -x .strtab -x .strtab %p/Inputs/trivial.obj.elf-x86-64 2>&1 | \
# RUN: FileCheck %s --check-prefix=ELF
# RUN: llvm-readobj -x 9 -x .strtab -x 10 -x not_exist \
# RUN: %p/Inputs/trivial.obj.elf-x86-64 2>&1 | FileCheck %s -DFILE=%p/Inputs/trivial.obj.elf-x86-64 --check-prefixes=ELF-WARN,ELF
# RUN: %p/Inputs/trivial.obj.elf-x86-64 2>&1 | FileCheck %s --check-prefixes=ELF-WARN,ELF

# ELF-SEC: [ 9] .strtab

# ELF-WARN: warning: '[[FILE]]': could not find section 'not_exist'
# ELF-WARN: warning: '[[FILE]]': could not find section 10
# ELF-WARN: warning: could not find section 'not_exist'
# ELF-WARN: warning: could not find section 10
# ELF: Hex dump of section '.strtab':
# ELF-NEXT: 0x00000000 00747269 7669616c 2e6c6c00 6d61696e .trivial.ll.main
# ELF-NEXT: 0x00000010 002e4c2e 73747200 70757473 00536f6d ..L.str.puts.Som
@@ -1,5 +1,5 @@
RUN: not llvm-readobj --mips-plt-got %p/Inputs/relocs.obj.elf-mips 2>&1 | \
RUN: FileCheck %s -DFILE=%p/Inputs/relocs.obj.elf-mips -check-prefix GOT-OBJ
RUN: FileCheck %s -check-prefix GOT-OBJ
RUN: llvm-readobj --mips-plt-got %p/Inputs/dynamic-table-exe.mips | \
RUN: FileCheck %s -check-prefix GOT-EXE
RUN: llvm-readobj --mips-plt-got %p/Inputs/dynamic-table-so.mips | \
@@ -12,7 +12,7 @@ RUN: llvm-readobj --mips-plt-got %p/Inputs/got-static.exe.mips | \
RUN: FileCheck %s -check-prefix GOT-STATIC

RUN: not llvm-readelf --mips-plt-got %p/Inputs/relocs.obj.elf-mips 2>&1 | \
RUN: FileCheck %s -DFILE=%p/Inputs/relocs.obj.elf-mips -check-prefix GNU-GOT-OBJ
RUN: FileCheck %s -check-prefix GNU-GOT-OBJ
RUN: llvm-readelf --mips-plt-got %p/Inputs/dynamic-table-exe.mips | \
RUN: FileCheck %s --strict-whitespace -check-prefix GNU-GOT-EXE
RUN: llvm-readelf --mips-plt-got %p/Inputs/dynamic-table-so.mips | \
@@ -24,7 +24,7 @@ RUN: FileCheck %s --strict-whitespace -check-prefix GNU-GOT-EMPTY
RUN: llvm-readelf --mips-plt-got %p/Inputs/got-static.exe.mips | \
RUN: FileCheck %s --strict-whitespace -check-prefix GNU-GOT-STATIC

GOT-OBJ: error: '[[FILE]]': Cannot find .got section
GOT-OBJ: error: Cannot find .got section

GOT-EXE: Primary GOT {
GOT-EXE-NEXT: Canonical gp value: 0x418880
@@ -380,7 +380,7 @@ GOT-STATIC-NEXT: }
GOT-STATIC-NEXT: ]
GOT-STATIC-NEXT: }

GNU-GOT-OBJ: error: '[[FILE]]': Cannot find .got section
GNU-GOT-OBJ: error: Cannot find .got section

GNU-GOT-EXE: Primary GOT:
GNU-GOT-EXE-NEXT: Canonical gp value: 00418880
@@ -8,8 +8,8 @@
# using the assembly shown with each test case.

# RUN: yaml2obj --docnum=1 %s -o %t1.o
# RUN: llvm-readelf -n %t1.o 2>&1 | FileCheck -DFILE=%t1.o %s --check-prefix=ERR-HEADER-SHORT
# ERR-HEADER-SHORT: warning: '[[FILE]]': malformed note: header too short
# RUN: llvm-readelf -n %t1.o 2>&1 | FileCheck %s --check-prefix=ERR-HEADER-SHORT
# ERR-HEADER-SHORT: warning: malformed note: header too short

# .section ".note.foo", "a"
# .align 4
@@ -38,8 +38,8 @@ ProgramHeaders:
- Section: .note.foo

# RUN: yaml2obj --docnum=2 %s -o %t2.o
# RUN: llvm-readelf -n %t2.o 2>&1 | FileCheck -DFILE=%t2.o %s --check-prefix=ERR-NULL-TERM
# ERR-NULL-TERM: warning: '[[FILE]]': malformed note: not NUL terminated
# RUN: llvm-readelf -n %t2.o 2>&1 | FileCheck %s --check-prefix=ERR-NULL-TERM
# ERR-NULL-TERM: warning: malformed note: not NUL terminated

# .section ".note.foo", "a"
# .align 4
@@ -73,8 +73,8 @@ ProgramHeaders:
- Section: .note.foo

# RUN: yaml2obj --docnum=3 %s -o %t3.o
# RUN: llvm-readelf -n %t3.o 2>&1 | FileCheck -DFILE=%t3.o %s --check-prefix=ERR-FILE-COUNT
# ERR-FILE-COUNT: warning: '[[FILE]]': malformed note: too short for number of files
# RUN: llvm-readelf -n %t3.o 2>&1 | FileCheck %s --check-prefix=ERR-FILE-COUNT
# ERR-FILE-COUNT: warning: malformed note: too short for number of files

# .section ".note.foo", "a"
# .align 4
@@ -108,8 +108,8 @@ ProgramHeaders:
- Section: .note.foo

# RUN: yaml2obj --docnum=4 %s -o %t4.o
# RUN: llvm-readelf -n %t4.o 2>&1 | FileCheck -DFILE=%t4.o %s --check-prefix=ERR-FILE-END-EARLY
# ERR-FILE-END-EARLY: warning: '[[FILE]]': malformed note: too few filenames
# RUN: llvm-readelf -n %t4.o 2>&1 | FileCheck %s --check-prefix=ERR-FILE-END-EARLY
# ERR-FILE-END-EARLY: warning: malformed note: too few filenames

# .section ".note.foo", "a"
# .align 4
@@ -51,14 +51,14 @@
# CHECK-NEXT: [ 3] null{{$}}
# CHECK-NOT: {{.}}

# RUN: llvm-readobj --string-dump=does_not_exist %t 2>&1 | FileCheck -DFILE=%t %s --check-prefix=WARN1
# RUN: llvm-readobj --string-dump=42 %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=WARN2
# RUN: llvm-readobj --string-dump=does_not_exist %t 2>&1 | FileCheck %s --check-prefix=WARN1
# RUN: llvm-readobj --string-dump=42 %t 2>&1 | FileCheck %s --check-prefix=WARN2

# RUN: llvm-readelf --string-dump=does_not_exist %t 2>&1 | FileCheck -DFILE=%t %s --check-prefix=WARN1
# RUN: llvm-readelf --string-dump=42 %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=WARN2
# RUN: llvm-readelf --string-dump=does_not_exist %t 2>&1 | FileCheck %s --check-prefix=WARN1
# RUN: llvm-readelf --string-dump=42 %t 2>&1 | FileCheck %s --check-prefix=WARN2

# WARN1: warning: '[[FILE]]': could not find section 'does_not_exist'
# WARN2: warning: '[[FILE]]': could not find section 42
# WARN1: warning: could not find section 'does_not_exist'
# WARN2: warning: could not find section 42

--- !ELF
FileHeader:

0 comments on commit c35d4c9

Please sign in to comment.
You can’t perform that action at this time.