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. 3 4# RUN: yaml2obj %s --docnum=1 -o %t.bad-size 5# RUN: llvm-readobj --all %t.bad-size 2>&1 \ 6# RUN: | FileCheck %s -DFILE=%t.bad-size --implicit-check-not=warning: --check-prefix WARN 7# RUN: llvm-readelf --all %t.bad-size 2>&1 \ 8# RUN: | FileCheck %s -DFILE=%t.bad-size --implicit-check-not=warning: --check-prefix WARN-GNU 9 10# WARN: warning: '[[FILE]]': invalid PT_DYNAMIC size (0x4){{$}} 11# WARN: warning: '[[FILE]]': SHT_DYNAMIC section with index 1 has invalid size (0x4){{$}} 12# WARN: warning: '[[FILE]]': no valid dynamic table was found 13# WARN-EMPTY: 14# WARN: File: 15# WARN: ProgramHeaders [ 16# WARN: Symbols [ 17# WARN: ] 18 19# WARN-GNU: warning: '[[FILE]]': invalid PT_DYNAMIC size (0x4){{$}} 20# WARN-GNU: warning: '[[FILE]]': SHT_DYNAMIC section with index 1 has invalid size (0x4){{$}} 21# WARN-GNU: warning: '[[FILE]]': no valid dynamic table was found 22# WARN-GNU-NEXT: ELF Header: 23# WARN-GNU: Symbol table '.symtab' contains 1 entries: 24# WARN-GNU: 0: 25 26--- !ELF 27FileHeader: 28 Class: ELFCLASS64 29 Data: ELFDATA2LSB 30 Type: ET_EXEC 31Sections: 32 - Name: .dynamic 33 Type: SHT_DYNAMIC 34 Address: 0x1000 35 Content: "01234567" 36Symbols: [] 37ProgramHeaders: 38 - Type: PT_LOAD 39 VAddr: 0x1000 40 FirstSec: .dynamic 41 LastSec: .dynamic 42 - Type: PT_DYNAMIC 43 VAddr: 0x1000 44 FirstSec: .dynamic 45 LastSec: .dynamic 46 47## Test handling of a .dynamic section with an invalid entsize (i.e. not 2 * sizeof(Elf_Dyn)). 48# RUN: yaml2obj %s --docnum=2 -o %t.bad-entsize 49# RUN: llvm-readobj --dynamic-table %t.bad-entsize | FileCheck %s --check-prefix BAD-ENTSIZE-LLVM 50# RUN: llvm-readelf --dynamic-table %t.bad-entsize | FileCheck %s --check-prefix BAD-ENTSIZE-GNU 51 52# BAD-ENTSIZE-LLVM: DynamicSection [ (2 entries) 53# BAD-ENTSIZE-LLVM-NEXT: Tag Type Name/Value 54# BAD-ENTSIZE-LLVM-NEXT: 0x0000000000000015 DEBUG 0x0 55# BAD-ENTSIZE-LLVM-NEXT: 0x0000000000000000 NULL 0x0 56# BAD-ENTSIZE-LLVM-NEXT: ] 57 58# BAD-ENTSIZE-GNU: Dynamic section at offset 0x{{.*}} contains 2 entries: 59# BAD-ENTSIZE-GNU-NEXT: Tag Type Name/Value 60# BAD-ENTSIZE-GNU-NEXT: 0x0000000000000015 (DEBUG) 0x0 61# BAD-ENTSIZE-GNU-NEXT: 0x0000000000000000 (NULL) 0x0 62 63--- !ELF 64FileHeader: 65 Class: ELFCLASS64 66 Data: ELFDATA2LSB 67 Type: ET_EXEC 68Sections: 69 - Name: .dynamic 70 Type: SHT_DYNAMIC 71 Address: 0x1000 72 EntSize: 0x2 73 Entries: 74 - Tag: DT_DEBUG 75 Value: 0 76 - Tag: DT_NULL 77 Value: 0 78Symbols: [] 79ProgramHeaders: 80 - Type: PT_LOAD 81 VAddr: 0x1000 82 FirstSec: .dynamic 83 LastSec: .dynamic 84 - Type: PT_DYNAMIC 85 VAddr: 0x1000 86 FirstSec: .dynamic 87 LastSec: .dynamic 88 89## Test handling of string references pointing past the end of the dynamic string table. 90# RUN: yaml2obj %s --docnum=3 -o %t.bad-string 91# RUN: llvm-readobj --dynamic-table %t.bad-string 2>&1 | \ 92# RUN: FileCheck %s --implicit-check-not=warning: --check-prefix BAD-STRING-LLVM -DFILE=%t.bad-string 93# RUN: llvm-readelf --dynamic-table %t.bad-string 2>&1 | \ 94# RUN: FileCheck %s --implicit-check-not=warning: --check-prefix BAD-STRING-GNU -DFILE=%t.bad-string 95 96# BAD-STRING-LLVM: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb6: it goes past the end of the table (0xb1) 97# BAD-STRING-LLVM: LoadName: <?> 98# BAD-STRING-LLVM: DynamicSection [ (10 entries) 99# BAD-STRING-LLVM-NEXT: Tag Type Name/Value 100# BAD-STRING-LLVM-NEXT: 0x0000000000000005 STRTAB 0x1000 101# BAD-STRING-LLVM-NEXT: 0x000000000000000A STRSZ 1 (bytes) 102# BAD-STRING-LLVM-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb2: it goes past the end of the table (0xb1) 103# BAD-STRING-LLVM-NEXT: 0x0000000000000001 NEEDED Shared library: [<?>] 104# BAD-STRING-LLVM-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb3: it goes past the end of the table (0xb1) 105# BAD-STRING-LLVM-NEXT: 0x000000007FFFFFFF FILTER Filter library: [<?>] 106# BAD-STRING-LLVM-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb4: it goes past the end of the table (0xb1) 107# BAD-STRING-LLVM-NEXT: 0x000000007FFFFFFD AUXILIARY Auxiliary library: [<?>] 108# BAD-STRING-LLVM-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb5: it goes past the end of the table (0xb1) 109# BAD-STRING-LLVM-NEXT: 0x000000007FFFFFFE USED Not needed object: [<?>] 110## Note: there is no "string table at offset 0xb0..." warning here, because it was printed earlier. 111# BAD-STRING-LLVM-NEXT: 0x000000000000000E SONAME Library soname: [<?>] 112# BAD-STRING-LLVM-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb7: it goes past the end of the table (0xb1) 113# BAD-STRING-LLVM-NEXT: 0x000000000000000F RPATH Library rpath: [<?>] 114# BAD-STRING-LLVM-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb8: it goes past the end of the table (0xb1) 115# BAD-STRING-LLVM-NEXT: 0x000000000000001D RUNPATH Library runpath: [<?>] 116# BAD-STRING-LLVM-NEXT: 0x0000000000000000 NULL 0x0 117# BAD-STRING-LLVM-NEXT: ] 118 119# BAD-STRING-GNU: Dynamic section at offset 0xb1 contains 10 entries: 120# BAD-STRING-GNU-NEXT: Tag Type Name/Value 121# BAD-STRING-GNU-NEXT: 0x0000000000000005 (STRTAB) 0x1000 122# BAD-STRING-GNU-NEXT: 0x000000000000000a (STRSZ) 1 (bytes) 123# BAD-STRING-GNU-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb2: it goes past the end of the table (0xb1) 124# BAD-STRING-GNU-NEXT: 0x0000000000000001 (NEEDED) Shared library: [<?>] 125# BAD-STRING-GNU-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb3: it goes past the end of the table (0xb1) 126# BAD-STRING-GNU-NEXT: 0x000000007fffffff (FILTER) Filter library: [<?>] 127# BAD-STRING-GNU-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb4: it goes past the end of the table (0xb1) 128# BAD-STRING-GNU-NEXT: 0x000000007ffffffd (AUXILIARY) Auxiliary library: [<?>] 129# BAD-STRING-GNU-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb5: it goes past the end of the table (0xb1) 130# BAD-STRING-GNU-NEXT: 0x000000007ffffffe (USED) Not needed object: [<?>] 131# BAD-STRING-GNU-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb6: it goes past the end of the table (0xb1) 132# BAD-STRING-GNU-NEXT: 0x000000000000000e (SONAME) Library soname: [<?>] 133# BAD-STRING-GNU-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb7: it goes past the end of the table (0xb1) 134# BAD-STRING-GNU-NEXT: 0x000000000000000f (RPATH) Library rpath: [<?>] 135# BAD-STRING-GNU-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb8: it goes past the end of the table (0xb1) 136# BAD-STRING-GNU-NEXT: 0x000000000000001d (RUNPATH) Library runpath: [<?>] 137# BAD-STRING-GNU-NEXT: 0x0000000000000000 (NULL) 0x0 138 139--- !ELF 140FileHeader: 141 Class: ELFCLASS64 142 Data: ELFDATA2LSB 143 Type: ET_EXEC 144Sections: 145 - Name: .dynstr 146 Type: SHT_STRTAB 147 Address: 0x1000 148 - Name: .dynamic 149 Type: SHT_DYNAMIC 150 Address: 0x1010 151 Entries: 152 - Tag: DT_STRTAB 153 Value: 0x1000 154 - Tag: DT_STRSZ 155 Value: 1 156 - Tag: DT_NEEDED 157 Value: 2 158 - Tag: DT_FILTER 159 Value: 3 160 - Tag: DT_AUXILIARY 161 Value: 4 162 - Tag: DT_USED 163 Value: 5 164 - Tag: DT_SONAME 165 Value: 6 166 - Tag: DT_RPATH 167 Value: 7 168 - Tag: DT_RUNPATH 169 Value: 8 170 - Tag: DT_NULL 171 Value: 0 172Symbols: [] 173ProgramHeaders: 174 - Type: PT_LOAD 175 VAddr: 0x1000 176 FirstSec: .dynstr 177 LastSec: .dynamic 178 - Type: PT_DYNAMIC 179 VAddr: 0x1010 180 FirstSec: .dynamic 181 LastSec: .dynamic 182 183## Test handling of DT_STRTAB pointing outside the file's address space. 184# RUN: yaml2obj %s --docnum=4 -o %t.bad-strtab 185 186# RUN: llvm-readobj --dynamic-table %t.bad-strtab 2>&1 >/dev/null | \ 187# RUN: FileCheck -DFILE=%t.bad-strtab %s --implicit-check-not=warning: --check-prefix=BAD-STRTAB-ERR 188# RUN: llvm-readelf --dynamic-table %t.bad-strtab 2>&1 >/dev/null | \ 189# RUN: FileCheck -DFILE=%t.bad-strtab %s --implicit-check-not=warning: --check-prefix=BAD-STRTAB-ERR 190# BAD-STRTAB-ERR: warning: '[[FILE]]': unable to parse DT_STRTAB: virtual address is not in any segment: 0x2000000 191# BAD-STRTAB-ERR: warning: '[[FILE]]': string table was not found 192# BAD-STRTAB-ERR-NOT:{{.}} 193 194# RUN: llvm-readobj --dynamic-table --needed-libs %t.bad-strtab 2>&1 | \ 195# RUN: FileCheck -DFILE=%t.bad-strtab %s --check-prefixes=BAD-STRTAB-ERR2,BAD-STRTAB,BAD-STRTAB-LLVM 196# RUN: llvm-readelf --dynamic-table --needed-libs %t.bad-strtab 2>&1 | \ 197# RUN: FileCheck -DFILE=%t.bad-strtab %s --check-prefixes=BAD-STRTAB-ERR2,BAD-STRTAB,BAD-STRTAB-GNU 198 199# BAD-STRTAB-ERR2: warning: '[[FILE]]': unable to parse DT_STRTAB: virtual address is not in any segment: 0x2000000 200# BAD-STRTAB-LLVM: LoadName: <Not found> 201# BAD-STRTAB: warning: '[[FILE]]': string table was not found 202# BAD-STRTAB-LLVM-NEXT: 0x0000000000000001 NEEDED Shared library: [<?>] 203# BAD-STRTAB-GNU-NEXT: 0x0000000000000001 (NEEDED) Shared library: [<?>] 204# BAD-STRTAB: NeededLibraries [ 205# BAD-STRTAB: <?> 206# BAD-STRTAB: ] 207 208--- !ELF 209FileHeader: 210 Class: ELFCLASS64 211 Data: ELFDATA2LSB 212 Type: ET_EXEC 213Sections: 214 - Name: .dynamic 215 Type: SHT_DYNAMIC 216 Address: 0x1000 217 Entries: 218## Two DT_STRTAB entries are needed to check that we don't report it twice. 219 - Tag: DT_STRTAB 220 Value: 0x2000000 221 - Tag: DT_STRTAB 222 Value: 0x2000000 223 - Tag: DT_STRSZ 224 Value: 10 225 - Tag: DT_NEEDED 226 Value: 1 227 - Tag: DT_NULL 228 Value: 0x0 229Symbols: [] 230ProgramHeaders: 231 - Type: PT_LOAD 232 VAddr: 0x1000 233 FirstSec: .dynamic 234 LastSec: .dynamic 235 - Type: PT_DYNAMIC 236 VAddr: 0x1000 237 FirstSec: .dynamic 238 LastSec: .dynamic 239 240## Test handling of other d_ptr tags pointing outside the file's address space. 241# RUN: yaml2obj %s --docnum=5 -o %t.bad-rela 242# RUN: llvm-readobj --dynamic-table %t.bad-rela 2>&1 | FileCheck -DFILE=%t.bad-rela %s --check-prefixes=CHECK,BAD-RELA 243# RUN: llvm-readelf --dynamic-table %t.bad-rela 2>&1 | FileCheck -DFILE=%t.bad-rela %s --check-prefixes=CHECK,BAD-RELA-GNU 244 245# CHECK: warning: '[[FILE]]': unable to parse DT_RELA: virtual address is not in any segment: 0x1000000 246 247# BAD-RELA: DynamicSection [ (2 entries) 248# BAD-RELA-NEXT: Tag Type Name/Value 249# BAD-RELA-NEXT: 0x0000000000000007 RELA 0x1000000 250# BAD-RELA-NEXT: 0x0000000000000000 NULL 0x0 251# BAD-RELA-NEXT: ] 252# BAD-RELA-GNU: Dynamic section at offset 0xb0 contains 2 entries: 253# BAD-RELA-GNU-NEXT: Tag Type Name/Value 254# BAD-RELA-GNU-NEXT: 0x0000000000000007 (RELA) 0x1000000 255# BAD-RELA-GNU-NEXT: 0x0000000000000000 (NULL) 0x0 256 257--- !ELF 258FileHeader: 259 Class: ELFCLASS64 260 Data: ELFDATA2LSB 261 Type: ET_EXEC 262Sections: 263 - Name: .dynamic 264 Type: SHT_DYNAMIC 265 Address: 0x1000 266 Entries: 267 - Tag: DT_RELA 268 Value: 0x1000000 269 - Tag: DT_NULL 270 Value: 0x0 271Symbols: [] 272ProgramHeaders: 273 - Type: PT_LOAD 274 VAddr: 0x1000 275 FirstSec: .dynamic 276 LastSec: .dynamic 277 - Type: PT_DYNAMIC 278 VAddr: 0x1000 279 FirstSec: .dynamic 280 LastSec: .dynamic 281 282## Check how we handle cases when the dynamic string table is not null-terminated. 283 284## Case A: the value of the DT_STRSZ tag is equal to the size of 285## the not null-terminated dynamic string table. 286# RUN: yaml2obj %s -DSTRSZ=7 --docnum=6 -o %t6 287# RUN: llvm-readobj --dynamic-table %t6 2>&1 | \ 288# RUN: FileCheck %s -DFILE=%t6 --implicit-check-not=warning: \ 289# RUN: --check-prefixes=NOT-TERMINATED,NOT-TERMINATED-LLVM,NOT-TERMINATED-GREQ 290# RUN: llvm-readelf --dynamic-table %t6 2>&1 | \ 291# RUN: FileCheck %s -DFILE=%t6 --implicit-check-not=warning: \ 292# RUN: --check-prefixes=NOT-TERMINATED,NOT-TERMINATED-GNU,NOT-TERMINATED-GREQ 293 294## Case B: the value of the DT_STRSZ tag is less than the size of 295## the not null-terminated dynamic string table. 296# RUN: yaml2obj %s -DSTRSZ=6 --docnum=6 -o %t7 297# RUN: llvm-readobj --dynamic-table %t7 2>&1 | \ 298# RUN: FileCheck %s -DFILE=%t7 --implicit-check-not=warning: \ 299# RUN: --check-prefixes=NOT-TERMINATED,NOT-TERMINATED-LLVM,NOT-TERMINATED-LESS 300# RUN: llvm-readelf --dynamic-table %t7 2>&1 | \ 301# RUN: FileCheck %s -DFILE=%t7 --implicit-check-not=warning: \ 302# RUN: --check-prefixes=NOT-TERMINATED,NOT-TERMINATED-GNU,NOT-TERMINATED-LESS 303 304## Case C: the value of the DT_STRSZ tag is one byte larger than the size of 305## the not null-terminated dynamic string table. 306# RUN: yaml2obj %s -DSTRSZ=8 --docnum=6 -o %t8 307# RUN: llvm-readobj --dynamic-table %t8 2>&1 | \ 308# RUN: FileCheck %s -DFILE=%t8 --implicit-check-not=warning: \ 309# RUN: --check-prefixes=NOT-TERMINATED,NOT-TERMINATED-LLVM,NOT-TERMINATED-GREQ 310# RUN: llvm-readelf --dynamic-table %t8 2>&1 | \ 311# RUN: FileCheck %s -DFILE=%t8 --implicit-check-not=warning: \ 312# RUN: --check-prefixes=NOT-TERMINATED,NOT-TERMINATED-GNU,NOT-TERMINATED-GREQ 313 314# NOT-TERMINATED-LLVM: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb4: the string table is not null-terminated 315# NOT-TERMINATED: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb0: the string table is not null-terminated 316# NOT-TERMINATED-NEXT: {{[(]?}}NEEDED{{[)]?}} Shared library: [<?>] 317# NOT-TERMINATED-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb1: the string table is not null-terminated 318# NOT-TERMINATED-NEXT: {{[(]?}}FILTER{{[)]?}} Filter library: [<?>] 319# NOT-TERMINATED-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb2: the string table is not null-terminated 320# NOT-TERMINATED-NEXT: {{[(]?}}AUXILIARY{{[)]?}} Auxiliary library: [<?>] 321# NOT-TERMINATED-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb3: the string table is not null-terminated 322# NOT-TERMINATED-NEXT: {{[(]?}}USED{{[)]?}} Not needed object: [<?>] 323# NOT-TERMINATED-GNU-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb4: the string table is not null-terminated 324# NOT-TERMINATED-NEXT: {{[(]?}}SONAME{{[)]?}} Library soname: [<?>] 325# NOT-TERMINATED-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb5: the string table is not null-terminated 326# NOT-TERMINATED-NEXT: {{[(]?}}RPATH{{[)]?}} Library rpath: [<?>] 327# NOT-TERMINATED-GREQ-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb6: the string table is not null-terminated 328# NOT-TERMINATED-LESS-NEXT: warning: '[[FILE]]': string table at offset 0xb0: unable to read the string at 0xb6: it goes past the end of the table (0xb6) 329# NOT-TERMINATED-NEXT: {{[(]?}}RUNPATH{{[)]?}} Library runpath: [<?>] 330# NOT-TERMINATED-NEXT: {{[(]?}}NULL{{[)]?}} 0x0 331 332--- !ELF 333FileHeader: 334 Class: ELFCLASS64 335 Data: ELFDATA2LSB 336 Type: ET_EXEC 337Sections: 338 - Name: .dynstr 339 Type: SHT_STRTAB 340 Address: 0x1000 341 Content: '746573742e736f' ## "test.so", not null terminated. 342 - Type: Fill 343 Pattern: "61626300" ## 'a', 'b', 'c', '\0'. 344 Size: "4" 345 - Name: .dynamic 346 Type: SHT_DYNAMIC 347 Address: 0x1100 348 Entries: 349 - Tag: DT_STRTAB 350 Value: 0x1000 351 - Tag: DT_STRSZ 352 Value: [[STRSZ]] 353 - Tag: DT_NEEDED 354 Value: 0 355 - Tag: DT_FILTER 356 Value: 1 357 - Tag: DT_AUXILIARY 358 Value: 2 359 - Tag: DT_USED 360 Value: 3 361 - Tag: DT_SONAME 362 Value: 4 363 - Tag: DT_RPATH 364 Value: 5 365 - Tag: DT_RUNPATH 366 Value: 6 367 - Tag: DT_NULL 368 Value: 0 369ProgramHeaders: 370 - Type: PT_LOAD 371 VAddr: 0x1000 372 FirstSec: .dynstr 373 LastSec: .dynamic 374 - Type: PT_DYNAMIC 375 VAddr: 0x1100 376 FirstSec: .dynamic 377 LastSec: .dynamic 378 379## Check that we emit an appropriate warning when the dynamic string table ends past the end of the file. 380 381## Case A: the value of DT_STRSZ tag is set so that the string table ends 382## right before the EOF. No warning should be emitted. 383# RUN: yaml2obj %s -DSTRSZ=0x210 --docnum=6 -o %t9.1 384# RUN: llvm-readobj --dynamic-table %t9.1 | \ 385# RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=BEFORE-THE-EOF 386# RUN: llvm-readelf --dynamic-table %t9.1 | \ 387# RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=BEFORE-THE-EOF 388 389## Note: The code reads the data in [DT_STRTAB, DT_STRTAB + DT_STRSZ] as the string table 390## as normal. Since the file ends with a zero byte, strings are dumped, but if it didn't, 391## we'd get <?> printed instead. The important bit is that we don't get the past the end warning. 392 393# BEFORE-THE-EOF: {{[(]?}}NEEDED{{[)]?}} Shared library: [test.soabc] 394# BEFORE-THE-EOF-NEXT: {{[(]?}}FILTER{{[)]?}} Filter library: [est.soabc] 395# BEFORE-THE-EOF-NEXT: {{[(]?}}AUXILIARY{{[)]?}} Auxiliary library: [st.soabc] 396# BEFORE-THE-EOF-NEXT: {{[(]?}}USED{{[)]?}} Not needed object: [t.soabc] 397# BEFORE-THE-EOF-NEXT: {{[(]?}}SONAME{{[)]?}} Library soname: [.soabc] 398# BEFORE-THE-EOF-NEXT: {{[(]?}}RPATH{{[)]?}} Library rpath: [soabc] 399# BEFORE-THE-EOF-NEXT: {{[(]?}}RUNPATH{{[)]?}} Library runpath: [oabc] 400# BEFORE-THE-EOF-NEXT: {{[(]?}}NULL{{[)]?}} 0x0 401 402## Case B: the value of DT_STRSZ tag is set so that the string table goes 1 byte past the EOF. 403# RUN: yaml2obj %s -DSTRSZ=0x211 --docnum=6 -o %t9.2 404# RUN: llvm-readobj --dynamic-table %t9.2 2>&1 | FileCheck %s -DFILE=%t9.2 --check-prefix=PAST-THE-EOF 405# RUN: llvm-readelf --dynamic-table %t9.2 2>&1 | FileCheck %s -DFILE=%t9.2 --check-prefix=PAST-THE-EOF 406 407# PAST-THE-EOF: warning: '[[FILE]]': the dynamic string table at 0xb0 goes past the end of the file (0x2c0) with DT_STRSZ = 0x211 408# PAST-THE-EOF: warning: '[[FILE]]': string table was not found 409# PAST-THE-EOF: {{[(]?}}NEEDED{{[)]?}} Shared library: [<?>] 410# PAST-THE-EOF-NEXT: {{[(]?}}FILTER{{[)]?}} Filter library: [<?>] 411# PAST-THE-EOF-NEXT: {{[(]?}}AUXILIARY{{[)]?}} Auxiliary library: [<?>] 412# PAST-THE-EOF-NEXT: {{[(]?}}USED{{[)]?}} Not needed object: [<?>] 413# PAST-THE-EOF-NEXT: {{[(]?}}SONAME{{[)]?}} Library soname: [<?>] 414# PAST-THE-EOF-NEXT: {{[(]?}}RPATH{{[)]?}} Library rpath: [<?>] 415# PAST-THE-EOF-NEXT: {{[(]?}}RUNPATH{{[)]?}} Library runpath: [<?>] 416# PAST-THE-EOF-NEXT: {{[(]?}}NULL{{[)]?}} 0x0 417 418## Check that we report a warning when we try to map an address, but loadable 419## segments appear unsorted by the p_vaddr member. In this case we are still 420## able to map an address. 421 422# RUN: yaml2obj %s --docnum=7 -o %t10 423# RUN: llvm-readobj --dynamic-table %t10 2>&1 | \ 424# RUN: FileCheck %s -DFILE=%t10 --implicit-check-not=warning: --check-prefixes=OUT-OF-ORDER,OUT-OF-ORDER-LLVM 425# RUN: llvm-readelf --dynamic-table %t10 2>&1 | \ 426# RUN: FileCheck %s -DFILE=%t10 --implicit-check-not=warning: --check-prefixes=OUT-OF-ORDER,OUT-OF-ORDER-GNU 427 428# OUT-OF-ORDER: warning: '[[FILE]]': loadable segments are unsorted by virtual address 429 430# OUT-OF-ORDER-LLVM: DynamicSection [ (2 entries) 431# OUT-OF-ORDER-LLVM-NEXT: Tag Type Name/Value 432# OUT-OF-ORDER-LLVM-NEXT: 0x0000000000000005 STRTAB 0x1000 433# OUT-OF-ORDER-LLVM-NEXT: 0x0000000000000000 NULL 0x0 434# OUT-OF-ORDER-LLVM-NEXT: ] 435 436# OUT-OF-ORDER-GNU: Dynamic section at offset 0xe9 contains 2 entries: 437# OUT-OF-ORDER-GNU-NEXT: Tag Type Name/Value 438# OUT-OF-ORDER-GNU-NEXT: 0x0000000000000005 (STRTAB) 0x1000 439# OUT-OF-ORDER-GNU-NEXT: 0x0000000000000000 (NULL) 0x0 440 441--- !ELF 442FileHeader: 443 Class: ELFCLASS64 444 Data: ELFDATA2LSB 445 Type: ET_EXEC 446Sections: 447 - Name: .dynstr 448 Type: SHT_STRTAB 449 Address: 0x1000 450 - Name: .dynamic 451 Type: SHT_DYNAMIC 452 Address: 0x1010 453 Entries: 454 - Tag: DT_STRTAB 455 Value: 0x1000 456 - Tag: DT_NULL 457 Value: 0 458Symbols: [] 459ProgramHeaders: 460 - Type: PT_LOAD 461 VAddr: 0x1010 462 FirstSec: .dynamic 463 LastSec: .dynamic 464 - Type: PT_LOAD 465 VAddr: 0x1000 466 FirstSec: .dynstr 467 LastSec: .dynstr 468 - Type: PT_DYNAMIC 469 VAddr: 0x1010 470 FirstSec: .dynamic 471 LastSec: .dynamic 472