xref: /llvm-project/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test (revision 1af309d0c2efd1dcd9e54a8306145d0bc731d874)
1## Check bad DT_STRTAB address.
2
3# RUN: yaml2obj %s -DSTRSZ_VALUE=0x0000000000000001 -DSTRTAB_ADDR=0x0000000000000260 -o %t
4# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s -DERR_ADDR=0x260
5
6
7## Check bad DT_STRSZ size.
8
9# RUN: yaml2obj %s -DSTRSZ_VALUE=0x0000000000001000 -DSTRTAB_ADDR=0x0000000000001000 -o %t
10# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s -DERR_ADDR=0x2000
11
12!ELF
13FileHeader:
14  Class:           ELFCLASS64
15  Data:            ELFDATA2LSB
16  Type:            ET_DYN
17  Machine:         EM_X86_64
18Sections:
19  - Name:            .dynstr
20    Type:            SHT_STRTAB
21    Flags:           [ SHF_ALLOC ]
22    Address:         0x1000
23    Content:         "00"
24  - Name:            .dynamic
25    Type:            SHT_DYNAMIC
26    Flags:           [ SHF_ALLOC ]
27    Address:         0x0000000000001008
28    Link:            .dynstr
29    AddressAlign:    0x0000000000000008
30    EntSize:         0x0000000000000010
31    Entries:
32      - Tag:             DT_SONAME
33        Value:           0x0000000000000000
34      - Tag:             DT_STRSZ
35        Value:           [[STRSZ_VALUE]]
36      - Tag:             DT_STRTAB
37        Value:           [[STRTAB_ADDR]]
38      - Tag:             DT_SYMTAB
39        Value:           0x0000000000001000
40      - Tag:             DT_NULL
41        Value:           0x0000000000000000
42ProgramHeaders:
43  - Type:     PT_LOAD
44    Flags:    [ PF_R ]
45    VAddr:    0x1000
46    Align:    8
47    FirstSec: .dynstr
48    LastSec:  .dynamic
49  - Type:     PT_DYNAMIC
50    Flags:    [ PF_X, PF_R ]
51    VAddr:    0x1008
52    FirstSec: .dynamic
53    LastSec:  .dynamic
54
55# CHECK: virtual address is not in any segment: [[ERR_ADDR]] when locating dynamic string table section contents
56