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] .symtab SYMTAB 0000000000000000 000040 000018 18 2 1 8
12 # DEFAULT-NEXT: [ 2] .strtab STRTAB 0000000000000000 000058 000001 00 0 0 1
13 # DEFAULT-NEXT: [ 3] .shstrtab STRTAB 0000000000000000 000059 00001b 00 0 0 1
22 ## Now define a SHT_NULL section with fields all zeroed.
23 ## In this case it is equal to the section created by default.
25 # RUN: yaml2obj --docnum=2 %s -o %t2
26 # RUN: llvm-readelf --sections %t2 | FileCheck %s --check-prefix=DEFAULT
45 ## Check we can redefine fields of the first SHT_NULL section.
47 # RUN: yaml2obj --docnum=3 %s -o %t3
48 # RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=REDEFINE
50 # REDEFINE: Section Headers:
51 # REDEFINE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
52 # REDEFINE-NEXT: [ 0] .foo NULL 0000000000000006 000000 000002 03 A 4 5 1
71 ## Check that file size does not change if we redefine the Size
72 ## of the first SHT_NULL section.
74 # RUN: yaml2obj --docnum=4 %s -o %t4
75 # RUN: ls -l %t3 | tr -s ' ' | cut -d ' ' -f 5 > %t.txt
76 # RUN: ls -l %t4 | tr -s ' ' | cut -d ' ' -f 5 >> %t.txt
77 # RUN: FileCheck %s --input-file=%t.txt --check-prefix=SIZE
79 # SIZE: [[FILESIZE:.*]]
99 ## Check we are still able to describe other sections too.
101 # RUN: yaml2obj --docnum=5 %s -o %t5
102 # RUN: llvm-readelf --sections %t5 | FileCheck %s --check-prefix=OTHER-SECTION
104 # OTHER-SECTION: Section Headers:
105 # OTHER-SECTION-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
106 # OTHER-SECTION-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
107 # OTHER-SECTION-NEXT: [ 1] foo PROGBITS 0000000000000000 000040 000000 00 0 0 0
108 # OTHER-SECTION-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000040 000018 18 3 1 8
109 # OTHER-SECTION-NEXT: [ 3] .strtab STRTAB 0000000000000000 000058 000001 00 0 0 1
110 # OTHER-SECTION-NEXT: [ 4] .shstrtab STRTAB 0000000000000000 000059 00001f 00 0 0 1
129 ## Check we report an error if null section sh_link field refers to an unknown section.
131 # RUN: not yaml2obj --docnum=6 %s -o %t6 2>&1 | FileCheck %s --check-prefix=CASE4
133 # CASE4: error: unknown section referenced: '.foo' by YAML section ''
145 ## Check that null section fields are set to zero, if they are unspecified.
147 # RUN: yaml2obj --docnum=7 %s -o %t7
148 # RUN: llvm-readelf --sections %t7 | FileCheck %s --check-prefix=DEFAULT
159 ## Check we do not crash if we have more than one SHT_NULL section.
161 # RUN: yaml2obj --docnum=8 %s -o %t8
162 # RUN: llvm-readelf --sections %t8 | FileCheck %s --check-prefix=MULTIPLE
164 # MULTIPLE: Section Headers:
165 # MULTIPLE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
166 # MULTIPLE-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
167 # MULTIPLE-NEXT: [ 1] .foo NULL 0000000000000123 000040 000020 10 A 1 2 0
186 ## Check we can override the sh_offset/sh_size fields of the first SHT_NULL section if requested.
188 # RUN: yaml2obj --docnum=9 %s -o %t9
189 # RUN: llvm-readelf --sections %t9 | FileCheck %s --check-prefix=OVERRIDE
191 # OVERRIDE: Section Headers:
192 # OVERRIDE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
193 # OVERRIDE-NEXT: [ 0] NULL 0000000000000000 000007 000008 00 0 0 0