@@ -42,18 +42,14 @@ Sections:
42
42
Info : 0
43
43
Address : 0x0
44
44
45
- # # Check we are still able to describe other sections too .
45
+ # # Check we can redefine fields of the first SHT_NULL section .
46
46
47
47
# 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
49
49
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
57
53
58
54
--- !ELF
59
55
FileHeader :
@@ -63,23 +59,25 @@ FileHeader:
63
59
Machine : EM_X86_64
64
60
Sections :
65
61
- 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.
76
73
77
74
# RUN: yaml2obj --docnum=4 %s -o %t4
78
- # RUN: llvm-readelf --sections %t4 | FileCheck %s --check-prefix=REDEFINE
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
78
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: [[FILESIZE:.*]]
80
+ # SIZE: [[FILESIZE]]
83
81
84
82
--- !ELF
85
83
FileHeader :
@@ -88,16 +86,28 @@ FileHeader:
88
86
Type : ET_REL
89
87
Machine : EM_X86_64
90
88
Sections :
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
96
98
97
- # # The same as above, but using a number as a Link value .
99
+ # # Check we are still able to describe other sections too .
98
100
99
101
# 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
101
111
102
112
--- !ELF
103
113
FileHeader :
@@ -106,11 +116,15 @@ FileHeader:
106
116
Type : ET_REL
107
117
Machine : EM_X86_64
108
118
Sections :
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
112
126
- Type : SHT_PROGBITS
113
- Name : . foo
127
+ Name : ' foo'
114
128
115
129
# # Check we report an error if null section sh_link field refers to an unknown section.
116
130
@@ -150,7 +164,7 @@ Sections:
150
164
# MULTIPLE: Section Headers:
151
165
# MULTIPLE-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
152
166
# 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
154
168
155
169
--- !ELF
156
170
FileHeader :
@@ -161,9 +175,31 @@ FileHeader:
161
175
Sections :
162
176
- Type : SHT_NULL
163
177
- Type : SHT_NULL
178
+ Name : .foo
164
179
Flags : [ SHF_ALLOC ]
165
180
Size : 0x20
166
181
EntSize : 0x10
167
182
Link : 1
168
183
Info : 2
169
184
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