xref: /llvm-project/llvm/test/tools/obj2yaml/ELF/section-group.yaml (revision 60df7c08b1f4447309c0c07fec1c8bc7267562fc)
1## Checks that the tool is able to read section groups from ELF.
2
3## Check how groups sections are dumped.
4## Check we don't dump the "EntSize" key when sh_entsize == 4.
5
6# RUN: yaml2obj %s -o %t1.o
7# RUN: obj2yaml %t1.o | FileCheck %s -DSEC=.rodata
8
9# CHECK:      - Name: .group
10# CHECK-NEXT:   Type: SHT_GROUP
11# CHECK-NEXT:   Link: .symtab
12# CHECK-NEXT:   Info: signature
13# CHECK-NEXT:   Members:
14# CHECK-NEXT:     - SectionOrType: GRP_COMDAT
15# CHECK-NEXT:     - SectionOrType: [[SEC]]
16# CHECK-NEXT: - Name:
17
18--- !ELF
19FileHeader:
20  Class: ELFCLASS64
21  Data:  ELFDATA2LSB
22  Type:  ET_REL
23Sections:
24  - Name:    .group
25    Type:    SHT_GROUP
26    Link:    .symtab
27    Info:    [[INFO=signature]]
28    EntSize: [[ENTSIZE=<none>]]
29    Members:
30      - SectionOrType: GRP_COMDAT
31      - SectionOrType: [[SEC=.rodata]]
32  - Name: .rodata
33    Type: SHT_PROGBITS
34Symbols:
35  - Name:    signature
36    Type:    STT_OBJECT
37    Section: .rodata
38
39## Document that yaml2obj can't dump the SHT_GROUP section when its sh_entsize != 4.
40
41# RUN: yaml2obj %s -DENTSIZE=0xfe -o %t1.entsize.o
42# RUN: not obj2yaml %t1.entsize.o 2>&1 | \
43# RUN:   FileCheck %s -DFILE=%t1.entsize.o --check-prefix=ENTSIZE
44
45# ENTSIZE: Error reading file: [[FILE]]: section [index 1] has invalid sh_entsize: expected 4, but got 254
46
47## Check we are able to dump members of the SHT_GROUP section even when
48## one of them has section index 0.
49
50# RUN: yaml2obj -DSEC=0 %s -o %tnull.o
51# RUN: obj2yaml %tnull.o | FileCheck %s -DSEC="''"
52
53## Check obj2yaml report an error when sh_info field of
54## group section contains invalid (too large) signature symbol index.
55
56# RUN: yaml2obj -DINFO=0xFF %s -o %t2.o
57# RUN: not obj2yaml %t2.o 2>&1 | FileCheck %s -DFILE=%t2.o --check-prefix=ERR
58
59# ERR: Error reading file: [[FILE]]: unable to get symbol from section [index 3]: invalid symbol index (255)
60