Skip to content

Commit a5b484c

Browse files
author
Georgii Rymar
committed
[obj2yaml][test] - Improve and fix section-group.yaml test.
It has multiple issues fixed by this patch: 1) It shouldn't test how llvm-readelf/yaml2obj works. 2) It should use "-NEXT" prefix for check lines. 3) It can use YAML macros, that allows to use a single YAML. 4) It should probably test the case when a group member is a null section. Differential revision: https://reviews.llvm.org/D93753
1 parent a94497a commit a5b484c

File tree

1 file changed

+23
-44
lines changed

1 file changed

+23
-44
lines changed
Lines changed: 23 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
11
## Checks that the tool is able to read section groups from ELF.
22

3-
# RUN: yaml2obj --docnum=1 %s -o %t1.o
4-
# RUN: llvm-readobj --elf-section-groups %t1.o | FileCheck %s -check-prefix=OBJ
5-
# RUN: obj2yaml %t1.o | FileCheck %s --check-prefix YAML
6-
7-
# OBJ: Groups {
8-
# OBJ-NEXT: Group {
9-
# OBJ-NEXT: Name: .group
10-
# OBJ-NEXT: Index: 1
11-
# OBJ-NEXT: Link: 3
12-
# OBJ-NEXT: Info: 1
13-
# OBJ-NEXT: Type: COMDAT (0x1)
14-
# OBJ-NEXT: Signature: signature
15-
# OBJ-NEXT: Section(s) in group [
16-
# OBJ-NEXT: .rodata (2)
17-
# OBJ-NEXT: ]
18-
# OBJ-NEXT: }
19-
# OBJ-NEXT: }
20-
21-
# YAML: - Name: .group
22-
# YAML: Type: SHT_GROUP
23-
# YAML: Link: .symtab
24-
# YAML: Info: signature
25-
# YAML: Members:
26-
# YAML: - SectionOrType: GRP_COMDAT
27-
# YAML: - SectionOrType: .rodata
3+
# RUN: yaml2obj %s -o %t1.o
4+
# RUN: obj2yaml %t1.o | FileCheck %s -DSEC=.rodata
5+
6+
# CHECK: - Name: .group
7+
# CHECK-NEXT: Type: SHT_GROUP
8+
# CHECK-NEXT: Link: .symtab
9+
# CHECK-NEXT: EntSize: 0x4
10+
# CHECK-NEXT: Info: signature
11+
# CHECK-NEXT: Members:
12+
# CHECK-NEXT: - SectionOrType: GRP_COMDAT
13+
# CHECK-NEXT: - SectionOrType: [[SEC]]
14+
# CHECK-NEXT: - Name:
2815

2916
--- !ELF
3017
FileHeader:
@@ -35,35 +22,27 @@ Sections:
3522
- Name: .group
3623
Type: SHT_GROUP
3724
Link: .symtab
38-
Info: signature
25+
Info: [[INFO=signature]]
3926
Members:
4027
- SectionOrType: GRP_COMDAT
41-
- SectionOrType: .rodata
28+
- SectionOrType: [[SEC=.rodata]]
4229
- Name: .rodata
4330
Type: SHT_PROGBITS
4431
Symbols:
4532
- Name: signature
4633
Type: STT_OBJECT
4734
Section: .rodata
4835

36+
## Check we are able to dump members of the SHT_GROUP section even when
37+
## one of them has section index 0.
38+
39+
# RUN: yaml2obj -DSEC=0 %s -o %tnull.o
40+
# RUN: obj2yaml %tnull.o | FileCheck %s -DSEC="''"
41+
4942
## Check obj2yaml report an error when sh_info field of
5043
## group section contains invalid (too large) signature symbol index.
5144

52-
# RUN: yaml2obj --docnum=2 %s -o %t2.o
53-
# RUN: not obj2yaml %t2.o 2>&1 | FileCheck %s --check-prefix ERR
54-
55-
--- !ELF
56-
FileHeader:
57-
Class: ELFCLASS64
58-
Data: ELFDATA2LSB
59-
Type: ET_REL
60-
Sections:
61-
- Name: .group
62-
Type: SHT_GROUP
63-
Link: .symtab
64-
Info: 0xFF
65-
Members:
66-
- SectionOrType: GRP_COMDAT
67-
Symbols: []
45+
# RUN: yaml2obj -DINFO=0xFF %s -o %t2.o
46+
# RUN: not obj2yaml %t2.o 2>&1 | FileCheck %s -DFILE=%t2.o --check-prefix=ERR
6847

69-
# ERR: Error reading file: {{.*}}2.o: unable to get symbol from section [index 2]: invalid symbol index (255)
48+
# ERR: Error reading file: [[FILE]]: unable to get symbol from section [index 3]: invalid symbol index (255)

0 commit comments

Comments
 (0)