1## Test how we create SHT_ARM_EXIDX sections.
2
3## Test that the content of SHT_ARM_EXIDX sections,
4## generated for 32/64-bit little/big endian targets is correct.
5## Also check that we can use a special EXIDX_CANTUNWIND (0x1) value for a Value field of an entry.
6# RUN: yaml2obj --docnum=1 -DENCODE=LSB -DCLASS=64 %s -o %t.le64
7# RUN: llvm-readobj --sections --section-data %t.le64 | FileCheck %s --check-prefixes=DEFAULT,LE
8# RUN: yaml2obj --docnum=1 -DENCODE=LSB -DCLASS=32 %s -o %t.le32
9# RUN: llvm-readobj --sections --section-data %t.le32 | FileCheck %s --check-prefixes=DEFAULT,LE
10# RUN: yaml2obj --docnum=1 -DENCODE=MSB -DCLASS=64 %s -o %t.be64
11# RUN: llvm-readobj --sections --section-data %t.be64 | FileCheck %s --check-prefixes=DEFAULT,BE
12# RUN: yaml2obj --docnum=1 -DENCODE=MSB -DCLASS=32 %s -o %t.be32
13# RUN: llvm-readobj --sections --section-data %t.be32 | FileCheck %s --check-prefixes=DEFAULT,BE
14
15# DEFAULT:      Name: .ARM.exidx (1)
16# DEFAULT-NEXT: Type: SHT_ARM_EXIDX (0x70000001)
17# DEFAULT-NEXT: Flags [ (0x0)
18# DEFAULT-NEXT: ]
19# DEFAULT-NEXT: Address: 0x0
20# DEFAULT-NEXT: Offset: 0x{{.*}}
21# DEFAULT-NEXT: Size: 16
22# DEFAULT-NEXT: Link: 0
23# DEFAULT-NEXT: Info: 0
24# DEFAULT-NEXT: AddressAlignment: 0
25# DEFAULT-NEXT: EntrySize: 0
26# DEFAULT-NEXT: SectionData (
27# LE-NEXT:       0000: DDCCBBAA 44332211 9988FFEE 01000000  |
28# BE-NEXT:       0000: AABBCCDD 11223344 EEFF8899 00000001  |
29# DEFAULT-NEXT: )
30
31--- !ELF
32FileHeader:
33  Class:   ELFCLASS[[CLASS=64]]
34  Data:    ELFDATA2[[ENCODE=LSB]]
35  Type:    ET_DYN
36  Machine: [[MACHINE=EM_ARM]]
37Sections:
38  - Name: .ARM.exidx
39    Type: SHT_ARM_EXIDX
40    Entries:
41      - Offset: 0xAABBCCDD
42        Value:  0x11223344
43      - Offset: 0xEEFF8899
44        Value:  EXIDX_CANTUNWIND
45
46## Check we only recognize the SHT_ARM_EXIDX section type when machine type is EM_ARM.
47# RUN: not yaml2obj --docnum=1 -DMACHINE=EM_NONE %s 2>&1 | FileCheck %s --check-prefix=UNKNOWN
48
49# UNKNOWN:      error: invalid hex32 number
50# UNKNOWN-NEXT:  Type: SHT_ARM_EXIDX
51
52## Check we can set arbitrary section properties for a SHT_ARM_EXIDX section.
53## Also check that we are able to specify none of "Entries", "Content" nor "Size" keys.
54
55# RUN: yaml2obj --docnum=2 %s -o %t.props.o
56# RUN: llvm-readelf --sections %t.props.o | FileCheck %s --check-prefix=PROPERTIES
57
58# PROPERTIES: [Nr] Name       Type      Address          Off    Size   ES Flg Lk    Inf Al
59# PROPERTIES: [ 1] .ARM.exidx ARM_EXIDX 0000000000001122 000055 000000 00 AMS 13124 0   85
60
61--- !ELF
62FileHeader:
63  Class:   ELFCLASS64
64  Data:    ELFDATA2LSB
65  Type:    ET_REL
66  Machine: EM_ARM
67Sections:
68  - Name:         .ARM.exidx
69    Type:         SHT_ARM_EXIDX
70    Flags:        [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
71    Address:      0x1122
72    Link:         0x3344
73    AddressAlign: 0x55
74    EntSize:      0x66
75
76## Check we can't use the "Entries" key together with the "Content" or "Size" keys.
77
78# RUN: not yaml2obj --docnum=3 -DSIZE=0 -DENT="[]" %s 2>&1 | \
79# RUN:   FileCheck %s --check-prefix=ENTRIES-ERR
80# RUN: not yaml2obj --docnum=3 -DCONTENT="'00'" -DENT="[]" %s 2>&1 | \
81# RUN:   FileCheck %s --check-prefix=ENTRIES-ERR
82
83# ENTRIES-ERR: error: "Entries" cannot be used with "Content" or "Size"
84
85--- !ELF
86FileHeader:
87  Class:   ELFCLASS64
88  Data:    ELFDATA2LSB
89  Type:    ET_REL
90  Machine: EM_ARM
91Sections:
92  - Name:    .ARM.exidx
93    Type:    SHT_ARM_EXIDX
94    Size:    [[SIZE=<none>]]
95    Content: [[CONTENT=<none>]]
96    Entries: [[ENT=<none>]]
97
98## Check we can use the "Content" key with the "Size" key when the size is greater
99## than or equal to the content size.
100
101# RUN: not yaml2obj --docnum=3 -DCONTENT="'00'" -DSIZE=0 %s 2>&1 | \
102# RUN:   FileCheck %s --check-prefix=CONTENT-SIZE-ERR
103
104# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
105
106# RUN: yaml2obj --docnum=3 -DCONTENT="'00'" -DSIZE=1 %s -o %t.cont.size.eq.o
107# RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
108# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="00"
109
110# RUN: yaml2obj --docnum=3 -DCONTENT="'00'" -DSIZE=2 %s -o %t.cont.size.gr.o
111# RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
112# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0000"
113
114# CHECK-CONTENT:      Name: .ARM.exidx
115# CHECK-CONTENT:      SectionData (
116# CHECK-CONTENT-NEXT:   0000: [[DATA]] |
117# CHECK-CONTENT-NEXT: )
118
119## Check we can use "Content" key alone to emit arbitrary content.
120
121# RUN: yaml2obj --docnum=3 -DCONTENT="'11223344'" %s -o %t.content.o
122# RUN: llvm-readobj --sections --section-data %t.content.o | \
123# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="11223344"
124
125## Check we can use "Size" key alone to emit content of an arbitrary size.
126
127# RUN: yaml2obj --docnum=3 -DSIZE=4 %s -o %t.size.o
128# RUN: llvm-readobj --sections --section-data %t.size.o | \
129# RUN:   FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="00000000"
130