1 ## Test handling of a dynamic section size which is not a multiple of its entry size.
2 ## Test the full output to demonstrate how we print the warnings.
4 # RUN: yaml2obj %s --docnum=1 -o %t.bad-size
5 # RUN: llvm-readobj --all %t.bad-size 2>&1 \
6 # RUN: | FileCheck %s --implicit-check-not=warning --check-prefix WARN
7 # RUN: llvm-readelf --all %t.bad-size 2>&1 \
8 # RUN: | FileCheck %s --implicit-check-not=warning --check-prefix WARN-GNU
11 # WARN: warning: invalid section size (4) or entity size (16)
17 ## A warning is printed at the place where a normal dynamic table should be.
18 # WARN-NEXT: warning: invalid section size (4) or entity size (16)
19 # WARN-NEXT: ProgramHeaders [
21 # WARN-GNU-NOT: warning
22 # WARN-GNU: warning: invalid section size (4) or entity size (16)
23 # WARN-GNU-NEXT: ELF Header:
24 # WARN-GNU: Symbol table '.symtab' contains 1 entries:
27 ## A warning is printed at the place where a normal dynamic table should be.
28 # WARN-GNU: warning: invalid section size (4) or entity size (16)
52 ## Test handling of a .dynamic section with an invalid entsize (i.e. not 2 * sizeof(Elf_Dyn)).
53 # RUN: yaml2obj %s --docnum=2 -o %t.bad-entsize
54 # RUN: llvm-readobj --dynamic-table %t.bad-entsize | FileCheck %s --check-prefix BAD-ENTSIZE-LLVM
55 # RUN: llvm-readelf --dynamic-table %t.bad-entsize | FileCheck %s --check-prefix BAD-ENTSIZE-GNU
57 # BAD-ENTSIZE-LLVM: DynamicSection [ (2 entries)
58 # BAD-ENTSIZE-LLVM-NEXT: Tag Type Name/Value
59 # BAD-ENTSIZE-LLVM-NEXT: 0x0000000000000015 DEBUG 0x0
60 # BAD-ENTSIZE-LLVM-NEXT: 0x0000000000000000 NULL 0x0
61 # BAD-ENTSIZE-LLVM-NEXT: ]
63 # BAD-ENTSIZE-GNU: Dynamic section at offset 0x{{.*}} contains 2 entries:
64 # BAD-ENTSIZE-GNU-NEXT: Tag Type Name/Value
65 # BAD-ENTSIZE-GNU-NEXT: 0x0000000000000015 (DEBUG) 0x0
66 # BAD-ENTSIZE-GNU-NEXT: 0x0000000000000000 (NULL) 0x0
94 ## Test handling of string references pointing past the end of the dynamic string table.
95 # RUN: yaml2obj %s --docnum=3 -o %t.bad-string
96 # RUN: llvm-readobj --dynamic-table %t.bad-string | FileCheck %s --check-prefix BAD-STRING-LLVM
97 # RUN: llvm-readelf --dynamic-table %t.bad-string | FileCheck %s --check-prefix BAD-STRING-GNU
99 # BAD-STRING-LLVM: 0x000000000000000A STRSZ 1 (bytes)
100 # BAD-STRING-LLVM: 0x0000000000000001 NEEDED Shared library: <Invalid offset 0x1>
101 # BAD-STRING-LLVM: 0x000000007FFFFFFF FILTER Filter library: <Invalid offset 0x1>
102 # BAD-STRING-LLVM: 0x000000007FFFFFFD AUXILIARY Auxiliary library: <Invalid offset 0x1>
103 # BAD-STRING-LLVM: 0x000000007FFFFFFE USED Not needed object: <Invalid offset 0x1>
104 # BAD-STRING-LLVM: 0x000000000000000E SONAME Library soname: <Invalid offset 0x1>
105 # BAD-STRING-LLVM: 0x000000000000000F RPATH Library rpath: <Invalid offset 0x1>
106 # BAD-STRING-LLVM: 0x000000000000001D RUNPATH Library runpath: <Invalid offset 0x1>
108 # BAD-STRING-GNU: 0x000000000000000a (STRSZ) 1 (bytes)
109 # BAD-STRING-GNU: 0x0000000000000001 (NEEDED) Shared library: <Invalid offset 0x1>
110 # BAD-STRING-GNU: 0x000000007fffffff (FILTER) Filter library: <Invalid offset 0x1>
111 # BAD-STRING-GNU: 0x000000007ffffffd (AUXILIARY) Auxiliary library: <Invalid offset 0x1>
112 # BAD-STRING-GNU: 0x000000007ffffffe (USED) Not needed object: <Invalid offset 0x1>
113 # BAD-STRING-GNU: 0x000000000000000e (SONAME) Library soname: <Invalid offset 0x1>
114 # BAD-STRING-GNU: 0x000000000000000f (RPATH) Library rpath: <Invalid offset 0x1>
115 # BAD-STRING-GNU: 0x000000000000001d (RUNPATH) Library runpath: <Invalid offset 0x1>
162 ## Test handling of DT_STRTAB pointing outside the file's address space.
163 # RUN: yaml2obj %s --docnum=4 -o %t.bad-strtab
165 # RUN: llvm-readobj --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck %s --check-prefix BAD-STRTAB-ERR
166 # RUN: llvm-readelf --dynamic-table %t.bad-strtab 2>&1 >/dev/null | FileCheck %s --check-prefix BAD-STRTAB-ERR
167 # BAD-STRTAB-ERR: warning: Unable to parse DT_STRTAB: virtual address is not in any segment: 0x2000000
169 # RUN: llvm-readobj --dynamic-table --needed-libs %t.bad-strtab | FileCheck %s --check-prefixes=BAD-STRTAB,BAD-STRTAB-LLVM
170 # RUN: llvm-readelf --dynamic-table --needed-libs %t.bad-strtab | FileCheck %s --check-prefixes=BAD-STRTAB,BAD-STRTAB-GNU
171 # BAD-STRTAB-LLVM: LoadName: <Not found>
172 # BAD-STRTAB-LLVM: 0x0000000000000001 NEEDED Shared library: <String table is empty or was not found>
173 # BAD-STRTAB-GNU: 0x0000000000000001 (NEEDED) Shared library: <String table is empty or was not found>
174 # BAD-STRTAB: NeededLibraries [
175 # BAD-STRTAB: <Library name index out of range>
207 ## Test handling of other d_ptr tags pointing outside the file's address space.
208 # RUN: yaml2obj %s --docnum=5 -o %t.bad-rela
209 # RUN: llvm-readobj --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefixes=CHECK,BAD-RELA
210 # RUN: llvm-readelf --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefixes=CHECK,BAD-RELA-GNU
212 # CHECK: warning: Unable to parse DT_RELA: virtual address is not in any segment: 0x1000000
214 # BAD-RELA: DynamicSection [ (2 entries)
215 # BAD-RELA-NEXT: Tag Type Name/Value
216 # BAD-RELA-NEXT: 0x0000000000000007 RELA 0x1000000
217 # BAD-RELA-NEXT: 0x0000000000000000 NULL 0x0
219 # BAD-RELA-GNU: Dynamic section at offset 0x1f0 contains 2 entries:
220 # BAD-RELA-GNU-NEXT: Tag Type Name/Value
221 # BAD-RELA-GNU-NEXT: 0x0000000000000007 (RELA) 0x1000000
222 # BAD-RELA-GNU-NEXT: 0x0000000000000000 (NULL) 0x0