1## Check that llvm-readelf and llvm-readobj can
2## dump SHT_GROUP sections properly.
3
4# RUN: yaml2obj %s -o %t.o
5# RUN: llvm-readobj -g %t.o | FileCheck %s
6# RUN: llvm-readobj --elf-section-groups %t.o | FileCheck %s
7# RUN: llvm-readelf -g %t.o | FileCheck --check-prefix=GNU %s
8
9# CHECK:      Groups {
10# CHECK-NEXT:   Group {
11# CHECK-NEXT:     Name: .group
12# CHECK-NEXT:     Index: 1
13# CHECK-NEXT:     Link: 7
14# CHECK-NEXT:     Info: 1
15# CHECK-NEXT:     Type: COMDAT
16# CHECK-NEXT:     Signature: foo
17# CHECK-NEXT:     Section(s) in group [
18# CHECK-NEXT:       .text.foo
19# CHECK-NEXT:       .rela.text.foo
20# CHECK-NEXT:     ]
21# CHECK-NEXT:   }
22# CHECK-NEXT:   Group {
23# CHECK-NEXT:     Name: .group1
24# CHECK-NEXT:     Index: 2
25# CHECK-NEXT:     Link: 7
26# CHECK-NEXT:     Info: 2
27# CHECK-NEXT:     Type: COMDAT
28# CHECK-NEXT:     Signature: bar
29# CHECK-NEXT:     Section(s) in group [
30# CHECK-NEXT:       .text.bar
31# CHECK-NEXT:       .rela.text.bar
32# CHECK-NEXT:     ]
33# CHECK-NEXT:   }
34
35# GNU:      COMDAT group section [    1] `.group' [foo] contains 2 sections:
36# GNU-NEXT:  [Index]  Name
37# GNU-NEXT:  [    3] .text.foo
38# GNU-NEXT:  [    4] .rela.text.foo
39# GNU:      COMDAT group section [    2] `.group1' [bar] contains 2 sections:
40# GNU-NEXT:  [Index]  Name
41# GNU-NEXT:  [    5] .text.bar
42# GNU-NEXT:  [    6] .rela.text.bar
43
44--- !ELF
45FileHeader:
46  Class: ELFCLASS64
47  Data:  ELFDATA2LSB
48  Type:  ET_REL
49Sections:
50  - Name: .group
51    Type: SHT_GROUP
52    Link: [[SYMTAB1=.symtab]]
53    Info: foo
54    Members:
55      - SectionOrType: GRP_COMDAT
56      - SectionOrType: .text.foo
57      - SectionOrType: [[MEMBER1=.rela.text.foo]]
58    ShSize: [[SECSIZE1=<none>]]
59    ShName: [[GROUP1SHNAME=<none>]]
60  - Name: .group1
61    Type: SHT_GROUP
62    Link: [[SYMTAB2=.symtab]]
63    Info: bar
64    Members:
65      - SectionOrType: GRP_COMDAT
66      - SectionOrType: [[MEMBER2=.text.bar]]
67      - SectionOrType: .rela.text.bar
68    ShSize: [[SECSIZE2=<none>]]
69  - Name:  .text.foo
70    Type:  SHT_PROGBITS
71  - Name: .rela.text.foo
72    Type: SHT_RELA
73    Link: .symtab
74    Info: .text.foo
75  - Name:   .text.bar
76    Type:   SHT_PROGBITS
77    ShName: [[TEXTBARSHNAME=<none>]]
78  - Name: .rela.text.bar
79    Type: SHT_RELA
80    Link: .symtab
81    Info: .text.bar
82  - Name: .symtab
83    Type: SHT_SYMTAB
84    Link: [[SYMTABLINK=.strtab]]
85  - Name:    .strtab
86    Type:    SHT_STRTAB
87    Content: [[STRTABCONTENT=<none>]]
88Symbols:
89  - Name:    foo
90    Section: .text.foo
91    StName:  [[SYM1STNAME=<none>]]
92  - Name:    bar
93    Section: .text.bar
94    StName:  [[SYM2STNAME=<none>]]
95
96## Check that we report a warning and continue dumping when a section is included
97## in two group sections at the same time.
98
99# RUN: yaml2obj %s -DMEMBER2=.text.foo -o %t.dup.o
100# RUN: llvm-readobj --section-groups %t.dup.o 2>&1 | FileCheck %s -DFILE=%t.dup.o --check-prefix=DUP-LLVM
101# RUN: llvm-readelf --section-groups %t.dup.o 2>&1 | FileCheck %s -DFILE=%t.dup.o --check-prefix=DUP-GNU
102
103# DUP-LLVM:      Group {
104# DUP-LLVM-NEXT:   Name: .group
105# DUP-LLVM-NEXT:   Index: 1
106# DUP-LLVM-NEXT:   Link: 7
107# DUP-LLVM-NEXT:   Info: 1
108# DUP-LLVM-NEXT:   Type: COMDAT
109# DUP-LLVM-NEXT:   Signature: foo
110# DUP-LLVM-NEXT:   Section(s) in group [
111# DUP-LLVM-NEXT:     .text.foo (3)
112# DUP-LLVM-NEXT:     .rela.text.foo (4)
113# DUP-LLVM-NEXT:   ]
114# DUP-LLVM-NEXT: }
115# DUP-LLVM:      Group {
116# DUP-LLVM-NEXT:   Name: .group1
117# DUP-LLVM-NEXT:   Index: 2
118# DUP-LLVM-NEXT:   Link: 7
119# DUP-LLVM-NEXT:   Info: 2
120# DUP-LLVM-NEXT:   Type: COMDAT
121# DUP-LLVM-NEXT:   Signature: bar
122# DUP-LLVM-NEXT:   Section(s) in group [
123# DUP-LLVM-NEXT: warning: '[[FILE]]': section with index 3, included in the group section with index 1, was also found in the group section with index 2
124# DUP-LLVM-NEXT:     .text.foo (3)
125# DUP-LLVM-NEXT:     .rela.text.bar (6)
126# DUP-LLVM-NEXT:   ]
127# DUP-LLVM-NEXT: }
128
129# DUP-GNU:      COMDAT group section [    1] `.group' [foo] contains 2 sections:
130# DUP-GNU-NEXT:  [Index]    Name
131# DUP-GNU-NEXT:  [    3]   .text.foo
132# DUP-GNU-NEXT:  [    4]   .rela.text.foo
133
134# DUP-GNU:      COMDAT group section [    2] `.group1' [bar] contains 2 sections:
135# DUP-GNU-NEXT:    [Index]    Name
136# DUP-GNU-NEXT: warning: '[[FILE]]': section with index 3, included in the group section with index 1, was also found in the group section with index 2
137# DUP-GNU-NEXT:    [    3]   .text.foo
138# DUP-GNU-NEXT:    [    6]   .rela.text.bar
139
140## Check what we do when we are unable to dump the signature symbol name.
141## In this case the index of the string table section, linked to the symbol table used by a group section,
142## is broken (section does not exist).
143## Check we report a warning in this case. Check we don't print the same warning message twice.
144
145# RUN: yaml2obj %s -DSYMTABLINK=0xFF -o %t.symtab.o
146# RUN: llvm-readobj --section-groups %t.symtab.o 2>&1 | \
147# RUN:   FileCheck -DFILE=%t.symtab.o %s --check-prefix=SYMTAB-LLVM --implicit-check-not=warning:
148# RUN: llvm-readelf --section-groups %t.symtab.o 2>&1 | \
149# RUN:   FileCheck -DFILE=%t.symtab.o %s --check-prefix=SYMTAB-GNU --implicit-check-not=warning:
150
151# SYMTAB-LLVM:      Groups {
152# SYMTAB-LLVM-NEXT: warning: '[[FILE]]': unable to get the string table for SHT_SYMTAB section with index 7: invalid section index: 255
153# SYMTAB-LLVM-NEXT:   Group {
154# SYMTAB-LLVM-NEXT:     Name: .group (16)
155# SYMTAB-LLVM-NEXT:     Index: 1
156# SYMTAB-LLVM-NEXT:     Link: 7
157# SYMTAB-LLVM-NEXT:     Info: 1
158# SYMTAB-LLVM-NEXT:     Type: COMDAT (0x1)
159# SYMTAB-LLVM-NEXT:     Signature: <?>
160# SYMTAB-LLVM-NEXT:     Section(s) in group [
161# SYMTAB-LLVM-NEXT:       .text.foo (3)
162# SYMTAB-LLVM-NEXT:       .rela.text.foo (4)
163# SYMTAB-LLVM-NEXT:     ]
164# SYMTAB-LLVM-NEXT:   }
165# SYMTAB-LLVM-NEXT:   Group {
166# SYMTAB-LLVM-NEXT:     Name: .group1 (64)
167# SYMTAB-LLVM-NEXT:     Index: 2
168# SYMTAB-LLVM-NEXT:     Link: 7
169# SYMTAB-LLVM-NEXT:     Info: 2
170# SYMTAB-LLVM-NEXT:     Type: COMDAT (0x1)
171# SYMTAB-LLVM-NEXT:     Signature: <?>
172# SYMTAB-LLVM-NEXT:     Section(s) in group [
173# SYMTAB-LLVM-NEXT:       .text.bar (5)
174# SYMTAB-LLVM-NEXT:       .rela.text.bar (6)
175# SYMTAB-LLVM-NEXT:     ]
176# SYMTAB-LLVM-NEXT:   }
177# SYMTAB-LLVM-NEXT: }
178
179# SYMTAB-GNU:        warning: '[[FILE]]': unable to get the string table for SHT_SYMTAB section with index 7: invalid section index: 255
180# SYMTAB-GNU-EMPTY:
181# SYMTAB-GNU-NEXT:   COMDAT group section [    1] `.group' [<?>] contains 2 sections:
182# SYMTAB-GNU-NEXT:      [Index]    Name
183# SYMTAB-GNU-NEXT:      [    3]   .text.foo
184# SYMTAB-GNU-NEXT:      [    4]   .rela.text.foo
185# SYMTAB-GNU-EMPTY:
186# SYMTAB-GNU-NEXT:   COMDAT group section [    2] `.group1' [<?>] contains 2 sections:
187# SYMTAB-GNU-NEXT:      [Index]    Name
188# SYMTAB-GNU-NEXT:      [    5]   .text.bar
189# SYMTAB-GNU-NEXT:      [    6]   .rela.text.bar
190
191## This tests the behavior for two more cases when we are unable to dump the signature symbol name.
192## In the first case we link the group section to the section with index 255, which does not exist.
193## We check that a warning is reported when we are unable to locate the symbol table.
194## In the second case we link the SHT_GROUP section to itself. This documents that we don't check the
195## type of the linked section (we assume it is the symbol table) and checks that we report a warning
196## when we are unable to read a signature symbol.
197
198# RUN: yaml2obj %s -DSYMTAB1=0xFF -DSYMTAB2=0x1 -o %t.symtab2.o
199# RUN: llvm-readobj --section-groups %t.symtab2.o 2>&1 | \
200# RUN:   FileCheck -DFILE=%t.symtab2.o %s --check-prefix=SIGNATURE-LLVM --implicit-check-not=warning:
201# RUN: llvm-readelf --section-groups %t.symtab2.o 2>&1 | \
202# RUN:   FileCheck -DFILE=%t.symtab2.o %s --check-prefix=SIGNATURE-GNU --implicit-check-not=warning:
203
204# SIGNATURE:      Groups {
205# SIGNATURE-LLVM: warning: '[[FILE]]': unable to get the symbol table for SHT_GROUP section with index 1: invalid section index: 255
206# SIGNATURE-LLVM: warning: '[[FILE]]': unable to get the signature symbol for SHT_GROUP section with index 2: section [index 1] has invalid sh_entsize: expected 24, but got 4
207# SIGNATURE-LLVM:   Group {
208# SIGNATURE-LLVM:     Name: .group (16)
209# SIGNATURE-LLVM:     Index: 1
210# SIGNATURE-LLVM:     Link: 255
211# SIGNATURE-LLVM:     Info: 1
212# SIGNATURE-LLVM:     Type: COMDAT (0x1)
213# SIGNATURE-LLVM:     Signature: <?>
214# SIGNATURE-LLVM:     Section(s) in group [
215# SIGNATURE-LLVM:       .text.foo (3)
216# SIGNATURE-LLVM:       .rela.text.foo (4)
217# SIGNATURE-LLVM:     ]
218# SIGNATURE-LLVM:   }
219# SIGNATURE-LLVM:   Group {
220# SIGNATURE-LLVM:     Name: .group1 (64)
221# SIGNATURE-LLVM:     Index: 2
222# SIGNATURE-LLVM:     Link: 1
223# SIGNATURE-LLVM:     Info: 2
224# SIGNATURE-LLVM:     Type: COMDAT (0x1)
225# SIGNATURE-LLVM:     Signature: <?>
226# SIGNATURE-LLVM:     Section(s) in group [
227# SIGNATURE-LLVM:       .text.bar (5)
228# SIGNATURE-LLVM:       .rela.text.bar (6)
229# SIGNATURE-LLVM:     ]
230# SIGNATURE-LLVM:   }
231# SIGNATURE-LLVM: }
232
233# SIGNATURE-GNU:       warning: '[[FILE]]': unable to get the symbol table for SHT_GROUP section with index 1: invalid section index: 255
234# SIGNATURE-GNU-NEXT:  warning: '[[FILE]]': unable to get the signature symbol for SHT_GROUP section with index 2: section [index 1] has invalid sh_entsize: expected 24, but got 4
235# SIGNATURE-GNU-EMPTY:
236# SIGNATURE-GNU-NEXT:  COMDAT group section [    1] `.group' [<?>] contains 2 sections:
237# SIGNATURE-GNU-NEXT:     [Index]    Name
238# SIGNATURE-GNU-NEXT:     [    3]   .text.foo
239# SIGNATURE-GNU-NEXT:     [    4]   .rela.text.foo
240# SIGNATURE-GNU-EMPTY:
241# SIGNATURE-GNU-NEXT:  COMDAT group section [    2] `.group1' [<?>] contains 2 sections:
242# SIGNATURE-GNU-NEXT:     [Index]    Name
243# SIGNATURE-GNU-NEXT:     [    5]   .text.bar
244# SIGNATURE-GNU-NEXT:     [    6]   .rela.text.bar
245
246## Check we report a warning when the content of the group section is empty or can't be read.
247## In both cases we are unable to read the section group flag and dump it as 0.
248
249# RUN: yaml2obj %s -DSECSIZE1=0x0 -DSECSIZE2=0x1 -o %t.secsize.o
250# RUN: llvm-readobj --section-groups %t.secsize.o 2>&1 | \
251# RUN:   FileCheck -DFILE=%t.secsize.o %s --check-prefix=CONTENT-LLVM --implicit-check-not=warning:
252# RUN: llvm-readelf --section-groups %t.secsize.o 2>&1 | \
253# RUN:   FileCheck -DFILE=%t.secsize.o %s --check-prefix=CONTENT-GNU --implicit-check-not=warning:
254
255# CONTENT-LLVM:      Groups {
256# CONTENT-LLVM-NEXT: warning: '[[FILE]]': unable to read the section group flag from the SHT_GROUP section with index 1: the section is empty
257# CONTENT-LLVM-NEXT: warning: '[[FILE]]': unable to get the content of the SHT_GROUP section with index 2: section [index 2] has an invalid sh_size (1) which is not a multiple of its sh_entsize (4)
258# CONTENT-LLVM-NEXT:   Group {
259# CONTENT-LLVM-NEXT:     Name: .group (16)
260# CONTENT-LLVM-NEXT:     Index: 1
261# CONTENT-LLVM-NEXT:     Link: 7
262# CONTENT-LLVM-NEXT:     Info: 1
263# CONTENT-LLVM-NEXT:     Type: (unknown) (0x0)
264# CONTENT-LLVM-NEXT:     Signature: foo
265# CONTENT-LLVM-NEXT:     Section(s) in group [
266# CONTENT-LLVM-NEXT:     ]
267# CONTENT-LLVM-NEXT:   }
268# CONTENT-LLVM-NEXT:   Group {
269# CONTENT-LLVM-NEXT:     Name: .group1 (64)
270# CONTENT-LLVM-NEXT:     Index: 2
271# CONTENT-LLVM-NEXT:     Link: 7
272# CONTENT-LLVM-NEXT:     Info: 2
273# CONTENT-LLVM-NEXT:     Type: (unknown) (0x0)
274# CONTENT-LLVM-NEXT:     Signature: bar
275# CONTENT-LLVM-NEXT:     Section(s) in group [
276# CONTENT-LLVM-NEXT:     ]
277# CONTENT-LLVM-NEXT:   }
278# CONTENT-LLVM-NEXT: }
279
280# CONTENT-GNU:       warning: '[[FILE]]': unable to read the section group flag from the SHT_GROUP section with index 1: the section is empty
281# CONTENT-GNU:       warning: '[[FILE]]': unable to get the content of the SHT_GROUP section with index 2: section [index 2] has an invalid sh_size (1) which is not a multiple of its sh_entsize (4)
282# CONTENT-GNU-EMPTY:
283# CONTENT-GNU-NEXT:  (unknown) group section [    1] `.group' [foo] contains 0 sections:
284# CONTENT-GNU-NEXT:    [Index]    Name
285# CONTENT-GNU-EMPTY:
286# CONTENT-GNU-NEXT:  (unknown) group section [    2] `.group1' [bar] contains 0 sections:
287# CONTENT-GNU-NEXT:    [Index]    Name
288
289## Check that we emit a warning when we are unable to read the group section name or the name of a member.
290
291# RUN: yaml2obj %s -DGROUP1SHNAME=0xAAAA -DTEXTBARSHNAME=0xBBBB -o %t.name.o
292# RUN: llvm-readobj --section-groups %t.name.o 2>&1 | \
293# RUN:   FileCheck -DFILE=%t.name.o %s --check-prefix=NAME-LLVM --implicit-check-not=warning:
294# RUN: llvm-readelf --section-groups %t.name.o 2>&1 | \
295# RUN:   FileCheck -DFILE=%t.name.o %s --check-prefix=NAME-GNU --implicit-check-not=warning:
296
297# NAME-LLVM:      Groups {
298# NAME-LLVM-NEXT: warning: '[[FILE]]': unable to get the name of SHT_GROUP section with index 1: a section [index 1] has an invalid sh_name (0xaaaa) offset which goes past the end of the section name string table
299# NAME-LLVM-NEXT: warning: '[[FILE]]': unable to get the name of SHT_PROGBITS section with index 5: a section [index 5] has an invalid sh_name (0xbbbb) offset which goes past the end of the section name string table
300# NAME-LLVM-NEXT:   Group {
301# NAME-LLVM-NEXT:     Name: <?> (43690)
302# NAME-LLVM-NEXT:     Index: 1
303# NAME-LLVM-NEXT:     Link: 7
304# NAME-LLVM-NEXT:     Info: 1
305# NAME-LLVM-NEXT:     Type: COMDAT (0x1)
306# NAME-LLVM-NEXT:     Signature: foo
307# NAME-LLVM-NEXT:     Section(s) in group [
308# NAME-LLVM-NEXT:       .text.foo (3)
309# NAME-LLVM-NEXT:       .rela.text.foo (4)
310# NAME-LLVM-NEXT:     ]
311# NAME-LLVM-NEXT:   }
312# NAME-LLVM-NEXT:   Group {
313# NAME-LLVM-NEXT:     Name: .group1 (64)
314# NAME-LLVM-NEXT:     Index: 2
315# NAME-LLVM-NEXT:     Link: 7
316# NAME-LLVM-NEXT:     Info: 2
317# NAME-LLVM-NEXT:     Type: COMDAT (0x1)
318# NAME-LLVM-NEXT:     Signature: bar
319# NAME-LLVM-NEXT:     Section(s) in group [
320# NAME-LLVM-NEXT:       <?> (5)
321# NAME-LLVM-NEXT:       .rela.text.bar (6)
322# NAME-LLVM-NEXT:     ]
323# NAME-LLVM-NEXT:   }
324# NAME-LLVM-NEXT: }
325
326# NAME-GNU:        warning: '[[FILE]]': unable to get the name of SHT_GROUP section with index 1: a section [index 1] has an invalid sh_name (0xaaaa) offset which goes past the end of the section name string table
327# NAME-GNU-NEXT:   warning: '[[FILE]]': unable to get the name of SHT_PROGBITS section with index 5: a section [index 5] has an invalid sh_name (0xbbbb) offset which goes past the end of the section name string table
328# NAME-GNU-EMPTY:
329# NAME-GNU-NEXT:   COMDAT group section [    1] `<?>' [foo] contains 2 sections:
330# NAME-GNU-NEXT:      [Index]    Name
331# NAME-GNU-NEXT:      [    3]   .text.foo
332# NAME-GNU-NEXT:      [    4]   .rela.text.foo
333# NAME-GNU-EMPTY:
334# NAME-GNU-NEXT:  COMDAT group section [    2] `.group1' [bar] contains 2 sections:
335# NAME-GNU-NEXT:     [Index]    Name
336# NAME-GNU-NEXT:     [    5]   <?>
337# NAME-GNU-NEXT:     [    6]   .rela.text.bar
338
339## Check we report a warning then the section index of a section group member is invalid.
340
341# RUN: yaml2obj %s -DMEMBER1=0xEE -DMEMBER2=0xFF -o %t.member.index.o
342# RUN: llvm-readobj --section-groups %t.member.index.o 2>&1 | \
343# RUN:   FileCheck -DFILE=%t.member.index.o %s --check-prefix=MEMBER-LLVM --implicit-check-not=warning:
344# RUN: llvm-readelf --section-groups %t.member.index.o 2>&1 | \
345# RUN:   FileCheck -DFILE=%t.member.index.o %s --check-prefix=MEMBER-GNU --implicit-check-not=warning:
346
347# MEMBER-LLVM:      Groups {
348# MEMBER-LLVM-NEXT: warning: '[[FILE]]': unable to get the section with index 238 when dumping the SHT_GROUP section with index 1: invalid section index: 238
349# MEMBER-LLVM-NEXT: warning: '[[FILE]]': unable to get the section with index 255 when dumping the SHT_GROUP section with index 2: invalid section index: 255
350# MEMBER-LLVM-NEXT:   Group {
351# MEMBER-LLVM-NEXT:     Name: .group (16)
352# MEMBER-LLVM-NEXT:     Index: 1
353# MEMBER-LLVM-NEXT:     Link: 7
354# MEMBER-LLVM-NEXT:     Info: 1
355# MEMBER-LLVM-NEXT:     Type: COMDAT (0x1)
356# MEMBER-LLVM-NEXT:     Signature: foo
357# MEMBER-LLVM-NEXT:     Section(s) in group [
358# MEMBER-LLVM-NEXT:       .text.foo (3)
359# MEMBER-LLVM-NEXT:       <?> (238)
360# MEMBER-LLVM-NEXT:     ]
361# MEMBER-LLVM-NEXT:   }
362# MEMBER-LLVM-NEXT:   Group {
363# MEMBER-LLVM-NEXT:     Name: .group1 (64)
364# MEMBER-LLVM-NEXT:     Index: 2
365# MEMBER-LLVM-NEXT:     Link: 7
366# MEMBER-LLVM-NEXT:     Info: 2
367# MEMBER-LLVM-NEXT:     Type: COMDAT (0x1)
368# MEMBER-LLVM-NEXT:     Signature: bar
369# MEMBER-LLVM-NEXT:     Section(s) in group [
370# MEMBER-LLVM-NEXT:       <?> (255)
371# MEMBER-LLVM-NEXT:       .rela.text.bar (6)
372# MEMBER-LLVM-NEXT:     ]
373# MEMBER-LLVM-NEXT:   }
374# MEMBER-LLVM-NEXT: }
375
376# MEMBER-GNU:       warning: '[[FILE]]': unable to get the section with index 238 when dumping the SHT_GROUP section with index 1: invalid section index: 238
377# MEMBER-GNU-NEXT:  warning: '[[FILE]]': unable to get the section with index 255 when dumping the SHT_GROUP section with index 2: invalid section index: 255
378# MEMBER-GNU-EMPTY:
379# MEMBER-GNU-NEXT:  COMDAT group section [    1] `.group' [foo] contains 2 sections:
380# MEMBER-GNU-NEXT:     [Index]    Name
381# MEMBER-GNU-NEXT:     [    3]   .text.foo
382# MEMBER-GNU-NEXT:     [  238]   <?>
383# MEMBER-GNU-EMPTY:
384# MEMBER-GNU-NEXT:  COMDAT group section [    2] `.group1' [bar] contains 2 sections:
385# MEMBER-GNU-NEXT:     [Index]    Name
386# MEMBER-GNU-NEXT:     [  255]   <?>
387# MEMBER-GNU-NEXT:     [    6]   .rela.text.bar
388
389## Check warnings that are reported when the st_name field of the signature symbol goes past the end of the string table.
390
391## We set the content of the string table to '0061626300' ('\0abc\0') to fixup the size of the string table.
392## This makes it easier to test the boundary conditions.
393# RUN: yaml2obj %s -DSTRTABCONTENT="0061626300" -DSYM1STNAME=4 -DSYM2STNAME=5 -o %t.signame.o
394# RUN: llvm-readobj --section-groups %t.signame.o 2>&1 | \
395# RUN:   FileCheck -DFILE=%t.signame.o %s --check-prefixes=SIGNAME1-WARN,SIGNAME1-LLVM --implicit-check-not=warning:
396# RUN: llvm-readelf --section-groups %t.signame.o 2>&1 | \
397# RUN:   FileCheck -DFILE=%t.signame.o %s --check-prefixes=SIGNAME1-WARN,SIGNAME1-GNU --implicit-check-not=warning:
398
399# SIGNAME1-WARN: warning: '[[FILE]]': unable to get the name of the symbol with index 2: st_name (0x5) is past the end of the string table of size 0x5
400
401# SIGNAME1-LLVM: Signature: {{$}}
402# SIGNAME1-LLVM: Signature: <?>
403
404# SIGNAME1-GNU: COMDAT group section [    1] `.group' [] contains 2 sections:
405# SIGNAME1-GNU: COMDAT group section [    2] `.group1' [<?>] contains 2 sections:
406
407## Check we report a warning when the string table that contains the signature symbol name is not null-terminated.
408
409# RUN: yaml2obj %s -DSTRTABCONTENT="0061626361" -DSYM1STNAME=4 -DSYM2STNAME=5 -o %t.signame2.o
410# RUN: llvm-readobj --section-groups %t.signame2.o 2>&1 | \
411# RUN:   FileCheck -DFILE=%t.signame2.o %s --check-prefixes=SIGNAME2-WARN,SIGNAME2-LLVM --implicit-check-not=warning:
412# RUN: llvm-readelf --section-groups %t.signame2.o 2>&1 | \
413# RUN:   FileCheck -DFILE=%t.signame2.o %s --check-prefixes=SIGNAME2-WARN,SIGNAME2-GNU --implicit-check-not=warning:
414
415# SIGNAME2-WARN: warning: '[[FILE]]': unable to get the string table for SHT_SYMTAB section with index 7: SHT_STRTAB string table section [index 8] is non-null terminated
416
417# SIGNAME2-LLVM: Signature: <?>
418# SIGNAME2-LLVM: Signature: <?>
419
420# SIGNAME2-GNU: COMDAT group section [    1] `.group' [<?>] contains 2 sections:
421# SIGNAME2-GNU: COMDAT group section [    2] `.group1' [<?>] contains 2 sections:
422