@@ -42,18 +42,14 @@ Sections:
4242 Info : 0
4343 Address : 0x0
4444
45- # # Check we are still able to describe other sections too .
45+ # # Check we can redefine fields of the first SHT_NULL section .
4646
4747# RUN: yaml2obj --docnum=3 %s -o %t3
48- # RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=OTHER-SECTION
48+ # RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=REDEFINE
4949
50- # OTHER-SECTION: Section Headers:
51- # OTHER-SECTION-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
52- # OTHER-SECTION-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
53- # OTHER-SECTION-NEXT: [ 1] foo PROGBITS 0000000000000000 000180 000000 00 0 0 0
54- # OTHER-SECTION-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000180 000018 18 3 1 8
55- # OTHER-SECTION-NEXT: [ 3] .strtab STRTAB 0000000000000000 000198 000001 00 0 0 1
56- # OTHER-SECTION-NEXT: [ 4] .shstrtab STRTAB 0000000000000000 000199 00001f 00 0 0 1
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
5753
5854--- !ELF
5955FileHeader :
@@ -63,23 +59,25 @@ FileHeader:
6359 Machine : EM_X86_64
6460Sections :
6561 - Type : SHT_NULL
66- Name : ' '
67- Flags : [ ]
68- AddressAlign : 0x0
69- Size : 0x0
70- EntSize : 0x0
71- Link : 0
72- - Type : SHT_PROGBITS
73- Name : ' foo'
74-
75- # # Check we can redefine sh_size and sh_link fields of the SHT_NULL section.
62+ Name : .foo
63+ Flags : [ SHF_ALLOC ]
64+ AddressAlign : 0x1
65+ Size : 0x2
66+ EntSize : 0x3
67+ Link : 4
68+ Info : 5
69+ Address : 0x6
70+
71+ # # Check that file size does not change if we redefine the Size
72+ # # of the first SHT_NULL section.
7673
7774# RUN: yaml2obj --docnum=4 %s -o %t4
78- # RUN: llvm-readelf --sections %t4 | FileCheck %s --check-prefix=REDEFINE
75+ # RUN: stat %t3 > %t.txt
76+ # RUN: stat %t4 >> %t.txt
77+ # RUN: FileCheck %s --input-file=%t.txt --check-prefix=SIZE
7978
80- # REDEFINE: Section Headers:
81- # REDEFINE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
82- # REDEFINE-NEXT: [ 0] NULL 0000000000000000 000000 000123 00 1 0 0
79+ # SIZE: Size: [[FILESIZE:.*]]
80+ # SIZE: Size: [[FILESIZE]]
8381
8482--- !ELF
8583FileHeader :
@@ -88,16 +86,28 @@ FileHeader:
8886 Type : ET_REL
8987 Machine : EM_X86_64
9088Sections :
91- - Type : SHT_NULL
92- Link : .foo
93- Size : 0x123
94- - Type : SHT_PROGBITS
95- Name : .foo
89+ - Type : SHT_NULL
90+ Name : .foo
91+ Flags : [ SHF_ALLOC ]
92+ AddressAlign : 0x1
93+ Size : 0xFFFF
94+ EntSize : 0x3
95+ Link : 4
96+ Info : 5
97+ Address : 0x6
9698
97- # # The same as above, but using a number as a Link value .
99+ # # Check we are still able to describe other sections too .
98100
99101# RUN: yaml2obj --docnum=5 %s -o %t5
100- # RUN: llvm-readelf --sections %t5 | FileCheck %s --check-prefix=REDEFINE
102+ # RUN: llvm-readelf --sections %t5 | FileCheck %s --check-prefix=OTHER-SECTION
103+
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 000180 000000 00 0 0 0
108+ # OTHER-SECTION-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000180 000018 18 3 1 8
109+ # OTHER-SECTION-NEXT: [ 3] .strtab STRTAB 0000000000000000 000198 000001 00 0 0 1
110+ # OTHER-SECTION-NEXT: [ 4] .shstrtab STRTAB 0000000000000000 000199 00001f 00 0 0 1
101111
102112--- !ELF
103113FileHeader :
@@ -106,11 +116,15 @@ FileHeader:
106116 Type : ET_REL
107117 Machine : EM_X86_64
108118Sections :
109- - Type : SHT_NULL
110- Link : 1
111- Size : 0x123
119+ - Type : SHT_NULL
120+ Name : ' '
121+ Flags : [ ]
122+ AddressAlign : 0x0
123+ Size : 0x0
124+ EntSize : 0x0
125+ Link : 0
112126 - Type : SHT_PROGBITS
113- Name : . foo
127+ Name : ' foo'
114128
115129# # Check we report an error if null section sh_link field refers to an unknown section.
116130
@@ -150,7 +164,7 @@ Sections:
150164# MULTIPLE: Section Headers:
151165# MULTIPLE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
152166# MULTIPLE-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
153- # MULTIPLE-NEXT: [ 1] NULL 0000000000000123 000180 000020 10 A 1 2 0
167+ # MULTIPLE-NEXT: [ 1] .foo NULL 0000000000000123 000180 000020 10 A 1 2 0
154168
155169--- !ELF
156170FileHeader :
@@ -161,9 +175,31 @@ FileHeader:
161175Sections :
162176 - Type : SHT_NULL
163177 - Type : SHT_NULL
178+ Name : .foo
164179 Flags : [ SHF_ALLOC ]
165180 Size : 0x20
166181 EntSize : 0x10
167182 Link : 1
168183 Info : 2
169184 Address : 0x123
185+
186+ # # Check we can override the sh_offset/sh_size fields of the first SHT_NULL section if requested.
187+
188+ # RUN: yaml2obj --docnum=9 %s -o %t9
189+ # RUN: llvm-readelf --sections %t9 | FileCheck %s --check-prefix=OVERRIDE
190+
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
194+
195+ --- !ELF
196+ FileHeader :
197+ Class : ELFCLASS64
198+ Data : ELFDATA2LSB
199+ Type : ET_REL
200+ Machine : EM_X86_64
201+ Sections :
202+ - Type : SHT_NULL
203+ Size : 0x2
204+ ShOffset : 0x7
205+ ShSize : 0x8
0 commit comments