xref: /llvm-project/llvm/test/tools/obj2yaml/ELF/entsize.yaml (revision d5e48f1347d50e0da4926c5e41e12fd4700abd14)
1## Check how obj2yaml dumps the sh_entsize field.
2
3## Check we don't dump the "EntSize" key for SHT_SYMTAB/SHT_DYNSYM sections
4## when the value of sh_entsize is equal to sizeof(ELF_Sym) == 0x18.
5
6# RUN: yaml2obj %s -o %t
7# RUN: obj2yaml %t | FileCheck %s
8
9# CHECK:       - Name:    .rodata.cst4
10# CHECK-NEXT:    Type:    SHT_PROGBITS
11# CHECK-NEXT:    EntSize: 0x4
12# CHECK-NEXT:  - Name: .mysymtab
13# CHECK-NEXT:    Type: SHT_SYMTAB
14# CHECK-NEXT:    Link: .strtab
15# CHECK-NEXT:    Size: 0x0
16# CHECK-NEXT:  - Name: .mydynsym
17# CHECK-NEXT:    Type: SHT_DYNSYM
18# CHECK-NEXT:    Size: 0x0
19# CHECK-NEXT: ...
20
21--- !ELF
22FileHeader:
23  Class: ELFCLASS64
24  Data:  ELFDATA2LSB
25  Type:  ET_REL
26Sections:
27  - Name:    .rodata.cst4
28    Type:    SHT_PROGBITS
29    EntSize: 0x4
30  - Name:    .mysymtab
31    Type:    SHT_SYMTAB
32    EntSize: [[SYMTABES=0x18]]
33  - Name:    .mydynsym
34    Type:    SHT_DYNSYM
35    EntSize: [[DYNSYMES=0x18]]
36
37## Document that we are unable to dump a SHT_SYMTAB section when its entry size
38## is not equal to sizeof(ELF_Sym).
39
40# RUN: yaml2obj %s -DSYMTABES=0x19 -o %t2
41# RUN: not obj2yaml %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=ERR1
42
43# ERR1: Error reading file: [[FILE]]: section [index 2] has invalid sh_entsize: expected 24, but got 25
44
45## Document that we are unable to dump a SHT_DYNSYM section when its entry size
46## is not equal to sizeof(ELF_Sym).
47
48# RUN: yaml2obj %s -DDYNSYMES=0x19 -o %t3
49# RUN: not obj2yaml %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=ERR2
50
51# ERR2: Error reading file: [[FILE]]: section [index 3] has invalid sh_entsize: expected 24, but got 25
52