1 ## In this test we check that can redefine the null section in the YAML.
3 ## Test the default output first.
5 # RUN: yaml2obj --docnum=1 %s -o %t1
6 # RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=DEFAULT
8 # DEFAULT: Section Headers:
9 # DEFAULT-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
10 # DEFAULT-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
11 # DEFAULT-NEXT: [ 1] .strtab STRTAB 0000000000000000 000040 000001 00 0 0 1
12 # DEFAULT-NEXT: [ 2] .shstrtab STRTAB 0000000000000000 000041 000013 00 0 0 1
21 ## Now define a SHT_NULL section with fields all zeroed.
22 ## In this case it is equal to the section created by default.
24 # RUN: yaml2obj --docnum=2 %s -o %t2
25 # RUN: llvm-readelf --sections %t2 | FileCheck %s --check-prefix=DEFAULT
44 ## Check we can redefine fields of the first SHT_NULL section.
46 # RUN: yaml2obj --docnum=3 %s -o %t3
47 # RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=REDEFINE
49 # REDEFINE: Section Headers:
50 # REDEFINE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
51 # REDEFINE-NEXT: [ 0] .foo NULL 0000000000000006 000000 000002 03 A 4 5 1
70 ## Check that file size does not change if we redefine the Size
71 ## of the first SHT_NULL section.
73 # RUN: yaml2obj --docnum=4 %s -o %t4
74 # RUN: ls -l %t3 | tr -s ' ' | cut -d ' ' -f 5 > %t.txt
75 # RUN: ls -l %t4 | tr -s ' ' | cut -d ' ' -f 5 >> %t.txt
76 # RUN: FileCheck %s --input-file=%t.txt --check-prefix=SIZE
78 # SIZE: [[FILESIZE:.*]]
98 ## Check we are still able to describe other sections too.
100 # RUN: yaml2obj --docnum=5 %s -o %t5
101 # RUN: llvm-readelf --sections %t5 | FileCheck %s --check-prefix=OTHER-SECTION
103 # OTHER-SECTION: Section Headers:
104 # OTHER-SECTION-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
105 # OTHER-SECTION-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
106 # OTHER-SECTION-NEXT: [ 1] foo PROGBITS 0000000000000000 000040 000000 00 0 0 0
107 # OTHER-SECTION-NEXT: [ 2] .strtab STRTAB 0000000000000000 000040 000001 00 0 0 1
108 # OTHER-SECTION-NEXT: [ 3] .shstrtab STRTAB 0000000000000000 000041 000017 00 0 0 1
127 ## Check we report an error if null section sh_link field refers to an unknown section.
129 # RUN: not yaml2obj --docnum=6 %s -o %t6 2>&1 | FileCheck %s --check-prefix=CASE4
131 # CASE4: error: unknown section referenced: '.foo' by YAML section ''
143 ## Check that null section fields are set to zero, if they are unspecified.
145 # RUN: yaml2obj --docnum=7 %s -o %t7
146 # RUN: llvm-readelf --sections %t7 | FileCheck %s --check-prefix=DEFAULT
157 ## Check we do not crash if we have more than one SHT_NULL section.
159 # RUN: yaml2obj --docnum=8 %s -o %t8
160 # RUN: llvm-readelf --sections %t8 | FileCheck %s --check-prefix=MULTIPLE
162 # MULTIPLE: Section Headers:
163 # MULTIPLE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
164 # MULTIPLE-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
165 # MULTIPLE-NEXT: [ 1] .foo NULL 0000000000000123 000040 000020 10 A 1 2 0
184 ## Check we can override the sh_offset/sh_size fields of the first SHT_NULL section if requested.
186 # RUN: yaml2obj --docnum=9 %s -o %t9
187 # RUN: llvm-readelf --sections %t9 | FileCheck %s --check-prefix=OVERRIDE
189 # OVERRIDE: Section Headers:
190 # OVERRIDE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
191 # OVERRIDE-NEXT: [ 0] NULL 0000000000000000 000007 000008 00 0 0 0