1## Check how we dump SHT_GNU_verdef sections.
2## Check we don't dump the `Info` field when its value is equal
3## to the number of version definitions.
4
5# RUN: yaml2obj %s -o %t
6# RUN: obj2yaml %t | FileCheck %s
7
8# CHECK:       - Name:         .gnu.version_d
9# CHECK-NEXT:    Type:         SHT_GNU_verdef
10# CHECK-NEXT:    Flags:        [ SHF_ALLOC ]
11# CHECK-NEXT:    Address:      0x230
12# CHECK-NEXT:    Link:         .dynstr
13# CHECK-NEXT:    AddressAlign: 0x4
14# INFO-NEXT:     Info:         0x4
15# CHECK-NEXT:    Entries:
16# CHECK-NEXT:      - Names:
17# CHECK-NEXT:          - VERSION_0
18# CHECK-NEXT:      - Flags:      2
19# CHECK-NEXT:        VersionNdx: 2
20# CHECK-NEXT:        Hash:       108387921
21# CHECK-NEXT:        Names:
22# CHECK-NEXT:          - VERSION_1
23# CHECK-NEXT:      - Flags:      3
24# CHECK-NEXT:        VersionNdx: 3
25# CHECK-NEXT:        Hash:       108387922
26# CHECK-NEXT:        Names:
27# CHECK-NEXT:          - VERSION_2
28# CHECK-NEXT:          - VERSION_3
29# CHECK-NEXT:          - VERSION_4
30# CHECK-NEXT:  - Name:
31
32--- !ELF
33FileHeader:
34  Class: ELFCLASS64
35  Data:  ELFDATA2LSB
36  Type:  ET_DYN
37Sections:
38  - Name:            .gnu.version_d
39    Type:            SHT_GNU_verdef
40    Flags:           [ SHF_ALLOC ]
41    Address:         0x230
42    AddressAlign:    0x4
43    Info:            [[INFO=<none>]]
44    Entries:
45## An entry that has all fields explicitly set to their default values.
46## Used to check that we don't dump them.
47      - Version:    [[VERSION=1]]
48        Flags:      0
49        VersionNdx: 0
50        Hash:       0
51        Names:
52          - VERSION_0
53## An entry with arbitrary values.
54      - Flags:      2
55        VersionNdx: 2
56        Hash:       108387921
57        Names:
58          - VERSION_1
59## Another entry with arbitrary values and version predecessors.
60      - Flags:      3
61        VersionNdx: 3
62        Hash:       108387922
63        Names:
64          - VERSION_2
65          - VERSION_3
66          - VERSION_4
67## Needed to emit the .dynstr section.
68DynamicSymbols: []
69
70## Check we dump the `Info` field when its value is not equal
71## to the number of version definitions.
72
73# RUN: yaml2obj %s -DINFO=0x4 -o %t.info
74# RUN: obj2yaml %t.info | FileCheck %s --check-prefixes=CHECK,INFO
75
76## Document that we are not able to dump a version definition which
77## has a version revision (vd_version) that is not equal to 1.
78
79# RUN: yaml2obj %s -DVERSION=2 -o %t.version
80# RUN: not obj2yaml %t.version 2>&1 | \
81# RUN:   FileCheck %s -DFILE=%t.version --check-prefix=VERSION-ERR
82
83# VERSION-ERR: Error reading file: [[FILE]]: invalid SHT_GNU_verdef section version: 2
84