sections-ext.test
7.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
## This is a test case for --section-symbols, --section-relocations and
## --section-data command line flags and their aliases.
# RUN: yaml2obj %s -o %t
## Test --section-symbols (--st) displays symbols for each section.
# RUN: llvm-readobj --sections --st %t > %t.readobj-st
# RUN: llvm-readobj --sections --section-symbols %t > %t.readobj-st-no-alias
# RUN: diff %t.readobj-st %t.readobj-st-no-alias
# RUN: FileCheck %s --input-file=%t.readobj-st --check-prefixes=ALL,ST
## Test --section-relocations (--sr) displays relocations for each section.
# RUN: llvm-readobj --sections --sr %t > %t.readobj-sr
# RUN: llvm-readobj --sections --section-relocations %t > %t.readobj-sr-no-alias
# RUN: diff %t.readobj-sr %t.readobj-sr-no-alias
# RUN: FileCheck %s --input-file=%t.readobj-sr --check-prefixes=ALL,SR
## Test --section-data (--sd) displays section data for each section except SHT_NOBITS sections.
# RUN: llvm-readobj --sections --sd %t > %t.readobj-sd
# RUN: llvm-readobj --sections --section-data %t > %t.readobj-sd-no-alias
# RUN: diff %t.readobj-sd %t.readobj-sd-no-alias
# RUN: FileCheck %s --input-file=%t.readobj-sd --check-prefixes=ALL,SD
## Test all options together.
# RUN: llvm-readobj --sections --section-symbols --section-relocations --section-data %t | \
# RUN: FileCheck %s --check-prefixes=ALL,ST,SR,SD
# ALL: Sections [
# ALL-NEXT: Section {
# ALL-NEXT: Index: 0
# ALL-NEXT: Name: (0)
# ALL-NEXT: Type: SHT_NULL (0x0)
# ALL-NEXT: Flags [ (0x0)
# ALL-NEXT: ]
# ALL-NEXT: Address: 0x0
# ALL-NEXT: Offset: 0x0
# ALL-NEXT: Size: 0
# ALL-NEXT: Link: 0
# ALL-NEXT: Info: 0
# ALL-NEXT: AddressAlignment: 0
# ALL-NEXT: EntrySize: 0
# SR-NEXT: Relocations [
# SR-NEXT: ]
# ST-NEXT: Symbols [
# ST-NEXT: ]
# SD-NEXT: SectionData (
# SD-NEXT: )
# ALL-NEXT: }
# ALL-NEXT: Section {
# ALL-NEXT: Index: 1
# ALL-NEXT: Name: .text (6)
# ALL-NEXT: Type: SHT_PROGBITS (0x1)
# ALL-NEXT: Flags [ (0x0)
# ALL-NEXT: ]
# ALL-NEXT: Address: 0x0
# ALL-NEXT: Offset: 0x40
# ALL-NEXT: Size: 0
# ALL-NEXT: Link: 0
# ALL-NEXT: Info: 0
# ALL-NEXT: AddressAlignment: 0
# ALL-NEXT: EntrySize: 0
# SR-NEXT: Relocations [
# SR-NEXT: ]
# ST-NEXT: Symbols [
# ST-NEXT: Symbol {
# ST-NEXT: Name: foo (1)
# ST-NEXT: Value: 0x0
# ST-NEXT: Size: 0
# ST-NEXT: Binding: Local (0x0)
# ST-NEXT: Type: None (0x0)
# ST-NEXT: Other: 0
# ST-NEXT: Section: .text (0x1)
# ST-NEXT: }
# ST-NEXT: ]
# SD-NEXT: SectionData (
# SD-NEXT: )
# ALL-NEXT: }
# ALL-NEXT: Section {
# ALL-NEXT: Index: 2
# ALL-NEXT: Name: .rela.text (1)
# ALL-NEXT: Type: SHT_RELA (0x4)
# ALL-NEXT: Flags [ (0x0)
# ALL-NEXT: ]
# ALL-NEXT: Address: 0x0
# ALL-NEXT: Offset: 0x40
# ALL-NEXT: Size: 24
# ALL-NEXT: Link: 4
# ALL-NEXT: Info: 1
# ALL-NEXT: AddressAlignment: 0
# ALL-NEXT: EntrySize: 24
# SR-NEXT: Relocations [
# SR-NEXT: 0x0 R_X86_64_NONE - 0x0
# SR-NEXT: ]
# ST-NEXT: Symbols [
# ST-NEXT: ]
# SD-NEXT: SectionData (
# SD-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
# SD-NEXT: 0010: 00000000 00000000 |........|
# SD-NEXT: )
# ALL-NEXT: }
# ALL-NEXT: Section {
# ALL-NEXT: Index: 3
# ALL-NEXT: Name: .bss (12)
# ALL-NEXT: Type: SHT_NOBITS (0x8)
# ALL-NEXT: Flags [ (0x0)
# ALL-NEXT: ]
# ALL-NEXT: Address: 0x0
# ALL-NEXT: Offset: 0x58
# ALL-NEXT: Size: 4096
# ALL-NEXT: Link: 0
# ALL-NEXT: Info: 0
# ALL-NEXT: AddressAlignment: 0
# ALL-NEXT: EntrySize: 0
# SR-NEXT: Relocations [
# SR-NEXT: ]
# ST-NEXT: Symbols [
# ST-NEXT: ]
# ALL-NEXT: }
# ALL-NEXT: Section {
# ALL-NEXT: Index: 4
# ALL-NEXT: Name: .symtab (35)
# ALL-NEXT: Type: SHT_SYMTAB (0x2)
# ALL-NEXT: Flags [ (0x0)
# ALL-NEXT: ]
# ALL-NEXT: Address: 0x0
# ALL-NEXT: Offset: 0x58
# ALL-NEXT: Size: 48
# ALL-NEXT: Link: 5
# ALL-NEXT: Info: 2
# ALL-NEXT: AddressAlignment: 8
# ALL-NEXT: EntrySize: 24
# SR-NEXT: Relocations [
# SR-NEXT: ]
# ST-NEXT: Symbols [
# ST-NEXT: ]
# SD-NEXT: SectionData (
# SD-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
# SD-NEXT: 0010: 00000000 00000000 01000000 00000100 |................|
# SD-NEXT: 0020: 00000000 00000000 00000000 00000000 |................|
# SD-NEXT: )
# ALL-NEXT: }
# ALL-NEXT: Section {
# ALL-NEXT: Index: 5
# ALL-NEXT: Name: .strtab (27)
# ALL-NEXT: Type: SHT_STRTAB (0x3)
# ALL-NEXT: Flags [ (0x0)
# ALL-NEXT: ]
# ALL-NEXT: Address: 0x0
# ALL-NEXT: Offset: 0x88
# ALL-NEXT: Size: 5
# ALL-NEXT: Link: 0
# ALL-NEXT: Info: 0
# ALL-NEXT: AddressAlignment: 1
# ALL-NEXT: EntrySize: 0
# SR-NEXT: Relocations [
# SR-NEXT: ]
# ST-NEXT: Symbols [
# ST-NEXT: ]
# SD-NEXT: SectionData (
# SD-NEXT: 0000: 00666F6F 00 |.foo.|
# SD-NEXT: )
# ALL-NEXT: }
# ALL-NEXT: Section {
# ALL-NEXT: Index: 6
# ALL-NEXT: Name: .shstrtab (17)
# ALL-NEXT: Type: SHT_STRTAB (0x3)
# ALL-NEXT: Flags [ (0x0)
# ALL-NEXT: ]
# ALL-NEXT: Address: 0x0
# ALL-NEXT: Offset: 0x8D
# ALL-NEXT: Size: 43
# ALL-NEXT: Link: 0
# ALL-NEXT: Info: 0
# ALL-NEXT: AddressAlignment: 1
# ALL-NEXT: EntrySize: 0
# SR-NEXT: Relocations [
# SR-NEXT: ]
# ST-NEXT: Symbols [
# ST-NEXT: ]
# SD-NEXT: SectionData (
# SD-NEXT: 0000: 002E7265 6C612E74 65787400 2E627373 |..rela.text..bss|
# SD-NEXT: 0010: 002E7368 73747274 6162002E 73747274 |..shstrtab..strt|
# SD-NEXT: 0020: 6162002E 73796D74 616200 |ab..symtab.|
# SD-NEXT: )
# ALL-NEXT: }
# ALL-NEXT: ]
## Check that --section-symbols, --section-relocations and --section-data
## options produce no output without --sections.
# RUN: llvm-readobj --section-symbols --section-relocations --section-data %t | \
# RUN: FileCheck %s -DFILE=%t --check-prefix=NO-SECTIONS
# NO-SECTIONS: File: [[FILE]]
# NO-SECTIONS-NEXT: Format: elf64-x86-64
# NO-SECTIONS-NEXT: Arch: x86_64
# NO-SECTIONS-NEXT: AddressSize: 64bit
# NO-SECTIONS-NEXT: LoadName: <Not found>
# NO-SECTIONS-NOT: {{.}}
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
- Name: .rela.text
Type: SHT_RELA
Info: .text
Relocations:
- Type: R_X86_64_NONE
- Name: .bss
Type: SHT_NOBITS
Size: 0x1000
Symbols:
- Name: foo
Section: .text
## Check the output for an arbitrary section when --section-symbols is requested,
## but there is no symbol table in the object.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-readobj -S --section-symbols %t2 2>&1 | \
# RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=NOSYMTAB
# NOSYMTAB: Section {
# NOSYMTAB: Index: 1
# NOSYMTAB-NEXT: Name: .foo
# NOSYMTAB: Symbols [
# NOSYMTAB-NEXT: ]
# NOSYMTAB-NEXT: }
# NOSYMTAB-NEXT: Section {
# NOSYMTAB-NEXT: Index: 2
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .foo
Type: SHT_PROGBITS