1 ## Check that we correctly display the contents of the .stack_sizes section
2 ## in a relocatable object file.
4 # RUN: yaml2obj --docnum=1 %s -o %t01
5 # RUN: llvm-readelf --stack-sizes %t01 \
6 # RUN: | FileCheck %s --check-prefix=RELOC-GNU --strict-whitespace --match-full-lines
7 # RUN: llvm-readobj --stack-sizes %t01 | FileCheck %s --check-prefix=RELOC-LLVM
9 # RELOC-GNU: Size Functions
10 # RELOC-GNU-NEXT: 16 referenced_by_symbol_foo
11 # RELOC-GNU-NEXT: 32 referenced_via_section_bar
12 # RELOC-GNU-NEXT: 8 separate_text_section_baz
15 # RELOC-LLVM: StackSizes [
16 # RELOC-LLVM-NEXT: Entry {
17 # RELOC-LLVM-NEXT: Functions: [referenced_by_symbol_foo]
18 # RELOC-LLVM-NEXT: Size: 0x10
20 # RELOC-LLVM-NEXT: Entry {
21 # RELOC-LLVM-NEXT: Functions: [referenced_via_section_bar]
22 # RELOC-LLVM-NEXT: Size: 0x20
24 # RELOC-LLVM-NEXT: Entry {
25 # RELOC-LLVM-NEXT: Functions: [separate_text_section_baz]
26 # RELOC-LLVM-NEXT: Size: 0x8
51 - Name: '.stack_sizes (1)'
57 - Name: .rela.stack_sizes
61 ## A symbol relative reference.
63 Symbol: referenced_by_symbol_foo
65 ## A section relative reference.
70 - Name: '.rela.stack_sizes (1)'
72 Info: '.stack_sizes (1)'
75 Symbol: separate_text_section_baz
79 ShOffset: [[SYMTABOFFSET=<none>]]
81 - Name: separate_text_section_baz
82 Section: [[SEC1=.text.baz]]
84 Index: [[SEC1INDEX=<none>]]
88 - Name: referenced_by_symbol_foo
92 - Name: referenced_via_section_bar
98 ## Check that we report a warning when we are unable to read
99 ## the symbol table when dumping stack sizes.
101 # RUN: yaml2obj --docnum=1 %s -DSYMTABOFFSET=0xffffeeee -o %t01.broken.symtab
102 # RUN: llvm-readelf --stack-sizes %t01.broken.symtab 2>&1 | \
103 # RUN: FileCheck %s -DFILE=%t01.broken.symtab --check-prefix=SYMTAB-GNU --implicit-check-not=warning:
104 # RUN: llvm-readobj --stack-sizes %t01.broken.symtab 2>&1 | \
105 # RUN: FileCheck %s -DFILE=%t01.broken.symtab --check-prefix=SYMTAB-LLVM --implicit-check-not=warning:
107 # SYMTAB-GNU: Stack Sizes:
108 # SYMTAB-GNU-NEXT: Size Functions
109 # SYMTAB-GNU-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 0 in SHT_RELA section with index 5: unable to read an entry with index 3 from SHT_SYMTAB section with index 7: section [index 7] has a sh_offset (0xffffeeee) + sh_size (0x78) that is greater than the file size (0x450)
110 # SYMTAB-GNU-NEXT: warning: '[[FILE]]': unable to read the symbol table: section [index 7] has a sh_offset (0xffffeeee) + sh_size (0x78) that is greater than the file size (0x450)
111 # SYMTAB-GNU-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 3
112 # SYMTAB-GNU-NEXT: 16 ?
113 # SYMTAB-GNU-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 1 in SHT_RELA section with index 5: unable to read an entry with index 2 from SHT_SYMTAB section with index 7: section [index 7] has a sh_offset (0xffffeeee) + sh_size (0x78) that is greater than the file size (0x450)
114 # SYMTAB-GNU-NEXT: 32 ?
115 # SYMTAB-GNU-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 0 in SHT_RELA section with index 6: unable to read an entry with index 1 from SHT_SYMTAB section with index 7: section [index 7] has a sh_offset (0xffffeeee) + sh_size (0x78) that is greater than the file size (0x450)
116 # SYMTAB-GNU-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 4
117 # SYMTAB-GNU-NEXT: 8 ?
119 # SYMTAB-LLVM: StackSizes [
120 # SYMTAB-LLVM-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 0 in SHT_RELA section with index 5: unable to read an entry with index 3 from SHT_SYMTAB section with index 7: section [index 7] has a sh_offset (0xffffeeee) + sh_size (0x78) that is greater than the file size (0x450)
121 # SYMTAB-LLVM-NEXT: warning: '[[FILE]]': unable to read the symbol table: section [index 7] has a sh_offset (0xffffeeee) + sh_size (0x78) that is greater than the file size (0x450)
122 # SYMTAB-LLVM-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 3
123 # SYMTAB-LLVM-NEXT: Entry {
124 # SYMTAB-LLVM-NEXT: Functions: [?]
125 # SYMTAB-LLVM-NEXT: Size: 0x10
126 # SYMTAB-LLVM-NEXT: }
127 # SYMTAB-LLVM-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 1 in SHT_RELA section with index 5: unable to read an entry with index 2 from SHT_SYMTAB section with index 7: section [index 7] has a sh_offset (0xffffeeee) + sh_size (0x78) that is greater than the file size (0x450)
128 # SYMTAB-LLVM-NEXT: Entry {
129 # SYMTAB-LLVM-NEXT: Functions: [?]
130 # SYMTAB-LLVM-NEXT: Size: 0x20
131 # SYMTAB-LLVM-NEXT: }
132 # SYMTAB-LLVM-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 0 in SHT_RELA section with index 6: unable to read an entry with index 1 from SHT_SYMTAB section with index 7: section [index 7] has a sh_offset (0xffffeeee) + sh_size (0x78) that is greater than the file size (0x450)
133 # SYMTAB-LLVM-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 4
134 # SYMTAB-LLVM-NEXT: Entry {
135 # SYMTAB-LLVM-NEXT: Functions: [?]
136 # SYMTAB-LLVM-NEXT: Size: 0x8
137 # SYMTAB-LLVM-NEXT: }
138 # SYMTAB-LLVM-NEXT: ]
140 ## In this case we have a function symbol with an invalid section index.
141 ## Document what we dump.
143 # RUN: yaml2obj --docnum=1 %s -DSEC1="<none>" -DSEC1INDEX=0xFF -o %t01.broken.sym
144 # RUN: llvm-readelf --stack-sizes %t01.broken.sym 2>&1 | \
145 # RUN: FileCheck %s -DFILE=%t01.broken.sym --check-prefix=SYM-GNU --implicit-check-not=warning:
146 # RUN: llvm-readobj --stack-sizes %t01.broken.sym 2>&1 | \
147 # RUN: FileCheck %s -DFILE=%t01.broken.sym --check-prefix=SYM-LLVM --implicit-check-not=warning:
149 # SYM-GNU: Stack Sizes:
150 # SYM-GNU-NEXT: Size Functions
151 # SYM-GNU-NEXT: warning: '[[FILE]]': unable to get address of symbol 'separate_text_section_baz': invalid section index: 255
152 # SYM-GNU-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 3
155 # SYM-GNU-NEXT: warning: '[[FILE]]': cannot identify the section for relocation symbol 'separate_text_section_baz': invalid section index: 255
156 # SYM-GNU-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 4
159 # SYM-LLVM: StackSizes [
160 # SYM-LLVM-NEXT: warning: '[[FILE]]': unable to get address of symbol 'separate_text_section_baz': invalid section index: 255
161 # SYM-LLVM-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 3
162 # SYM-LLVM-NEXT: Entry {
163 # SYM-LLVM-NEXT: Functions: [?]
164 # SYM-LLVM-NEXT: Size: 0x10
166 # SYM-LLVM-NEXT: Entry {
167 # SYM-LLVM-NEXT: Functions: [?]
168 # SYM-LLVM-NEXT: Size: 0x20
170 # SYM-LLVM-NEXT: warning: '[[FILE]]': cannot identify the section for relocation symbol 'separate_text_section_baz': invalid section index: 255
171 # SYM-LLVM-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 4
172 # SYM-LLVM-NEXT: Entry {
173 # SYM-LLVM-NEXT: Functions: [?]
174 # SYM-LLVM-NEXT: Size: 0x8
178 ## Check that we correctly report the stack sizes in an executable (non-relocatable)
179 ## object file. This also shows that the sh_link field is ignored in this situation
182 # RUN: yaml2obj --docnum=2 %s -o %t02
183 # RUN: llvm-readelf --stack-sizes %t02 2>&1 \
184 # RUN: | FileCheck %s --check-prefix=EXEC-GNU --strict-whitespace \
185 # RUN: --match-full-lines --implicit-check-not=warning:
186 # RUN: llvm-readobj --stack-sizes %t02 2>&1 \
187 # RUN: | FileCheck %s --check-prefix=EXEC-LLVM --implicit-check-not=warning:
189 # EXEC-GNU: Size Functions
190 # EXEC-GNU-NEXT: 16 other
191 # EXEC-GNU-NEXT: 32 other_end
192 # EXEC-GNU-NEXT: 48 bar
195 # EXEC-LLVM: StackSizes [
196 # EXEC-LLVM-NEXT: Entry {
197 # EXEC-LLVM-NEXT: Functions: [other]
198 # EXEC-LLVM-NEXT: Size: 0x10
200 # EXEC-LLVM-NEXT: Entry {
201 # EXEC-LLVM-NEXT: Functions: [other_end]
202 # EXEC-LLVM-NEXT: Size: 0x20
204 # EXEC-LLVM-NEXT: Entry {
205 # EXEC-LLVM-NEXT: Functions: [bar]
206 # EXEC-LLVM-NEXT: Size: 0x30
235 ## Undefined symbols are ignored.
239 ## sh_link of .stack_sizes is ignored for non-reloctable objects.
256 ## Check that we report a warning when we find relocations whose offsets point outside
257 ## of the .stack_sizes section.
259 # RUN: yaml2obj --docnum=3 %s -o %t03
260 # RUN: llvm-readelf --stack-sizes %t03 2>&1 | FileCheck %s --check-prefix=SHORT-GNU -DFILE=%t03
261 # RUN: llvm-readobj --stack-sizes %t03 2>&1 | FileCheck %s --check-prefix=SHORT-LLVM -DFILE=%t03
263 # SHORT-GNU: Stack Sizes:
264 # SHORT-GNU-NEXT: Size Functions
265 # SHORT-GNU-NEXT: 8 foo
266 # SHORT-GNU-NEXT: warning: '[[FILE]]': found invalid relocation offset (0x1) into SHT_PROGBITS section with index 2 while trying to extract a stack size entry
267 # SHORT-GNU-NEXT: 8 foo
269 # SHORT-LLVM: StackSizes [
270 # SHORT-LLVM-NEXT: Entry {
271 # SHORT-LLVM-NEXT: Functions: [foo]
272 # SHORT-LLVM-NEXT: Size: 0x8
274 # SHORT-LLVM-NEXT: warning: '[[FILE]]': found invalid relocation offset (0x1) into SHT_PROGBITS section with index 2 while trying to extract a stack size entry
275 # SHORT-LLVM-NEXT: Entry {
276 # SHORT-LLVM-NEXT: Functions: [foo]
277 # SHORT-LLVM-NEXT: Size: 0x8
297 - Name: .rela.stack_sizes
319 ## Check that we warn about a function symbol that is not in the section
320 ## that is referenced by the stack sizes section's sh_link, for relocatable
323 # RUN: yaml2obj --docnum=4 %s -o %t04
324 # RUN: llvm-readelf --stack-sizes %t04 2> %t04-gnu.err | FileCheck %s --check-prefix=WRONGSECTION-GNU
325 # RUN: FileCheck %s < %t04-gnu.err --check-prefix=WRONGSECTION-ERR -DFILE=%t04
326 # RUN: llvm-readobj --stack-sizes %t04 2> %t04-llvm.err | FileCheck %s --check-prefix=WRONGSECTION-LLVM
327 # RUN: FileCheck %s < %t04-llvm.err --check-prefix=WRONGSECTION-ERR -DFILE=%t04
329 # RUN: llvm-readelf --stack-sizes --demangle %t04 2>&1 | FileCheck %s --check-prefix=WRONGSECTION-DEMANGLE-ERR -DFILE=%t04
330 # RUN: llvm-readobj --stack-sizes --demangle %t04 2>&1 | FileCheck %s --check-prefix=WRONGSECTION-DEMANGLE-ERR -DFILE=%t04
332 # WRONGSECTION-GNU: Size Functions
333 # WRONGSECTION-GNU-NEXT: 8 _Z3foof
335 # WRONGSECTION-LLVM: StackSizes [
336 # WRONGSECTION-LLVM-NEXT: Entry {
337 # WRONGSECTION-LLVM-NEXT: Functions: [_Z3foof]
338 # WRONGSECTION-LLVM-NEXT: Size: 0x8
339 # WRONGSECTION-LLVM-NEXT: }
340 # WRONGSECTION-LLVM-NEXT: ]
342 # WRONGSECTION-ERR: warning: '[[FILE]]': relocation symbol '_Z3foof' is not in the expected section
343 # WRONGSECTION-DEMANGLE-ERR: warning: '[[FILE]]': relocation symbol 'foo(float)' is not in the expected section
364 - Name: .rela.stack_sizes
377 ## Check that we report a warning when a stack sizes section ends with an incomplete stack size entry.
379 # RUN: yaml2obj --docnum=5 %s -o %t05
380 # RUN: llvm-readelf --stack-sizes %t05 2>&1 | \
381 # RUN: FileCheck %s --check-prefix=SUDDENEND-GNU -DFILE=%t05
382 # RUN: llvm-readobj --stack-sizes %t05 2>&1 | \
383 # RUN: FileCheck %s --check-prefix=SUDDENEND-LLVM -DFILE=%t05
385 # SUDDENEND-GNU: Stack Sizes:
386 # SUDDENEND-GNU-NEXT: Size Functions
387 # SUDDENEND-GNU-NEXT: 8 foo
388 # SUDDENEND-GNU-NEXT: warning: '[[FILE]]': SHT_PROGBITS section with index 2 ended while trying to extract a stack size entry
389 # SUDDENEND-GNU-NEXT: 8 foo
390 # SUDDENEND-GNU-NEXT: warning: '[[FILE]]': SHT_PROGBITS section with index 3 ended while trying to extract a stack size entry
392 # SUDDENEND-LLVM: StackSizes [
393 # SUDDENEND-LLVM-NEXT: Entry {
394 # SUDDENEND-LLVM-NEXT: Functions: [foo]
395 # SUDDENEND-LLVM-NEXT: Size: 0x8
396 # SUDDENEND-LLVM-NEXT: }
397 # SUDDENEND-LLVM-NEXT: warning: '[[FILE]]': SHT_PROGBITS section with index 2 ended while trying to extract a stack size entry
398 # SUDDENEND-LLVM-NEXT: Entry {
399 # SUDDENEND-LLVM-NEXT: Functions: [foo]
400 # SUDDENEND-LLVM-NEXT: Size: 0x8
401 # SUDDENEND-LLVM-NEXT: }
402 # SUDDENEND-LLVM-NEXT: warning: '[[FILE]]': SHT_PROGBITS section with index 3 ended while trying to extract a stack size entry
403 # SUDDENEND-LLVM-NEXT: ]
420 ## 0x11 == the normal size minus 1.
422 - Name: .stack_sizes (1)
434 ## Check that we report an invalid stack size, which is represented by a ULEB that
435 ## ends in a byte with the high bit set.
437 # RUN: yaml2obj --docnum=6 %s -o %t06
438 # RUN: llvm-readelf --stack-sizes %t06 2>&1 | \
439 # RUN: FileCheck %s --check-prefix=BADSIZE -DFILE=%t06 --implicit-check-not=warning:
440 # RUN: llvm-readobj --stack-sizes %t06 2>&1 | \
441 # RUN: FileCheck %s --check-prefix=BADSIZE -DFILE=%t06 --implicit-check-not=warning:
443 # BADSIZE: warning: '[[FILE]]': could not extract a valid stack size from SHT_PROGBITS section with index 2: unable to decode LEB128 at offset 0x00000008: malformed uleb128, extends past end
444 # BADSIZE: warning: '[[FILE]]': could not extract a valid stack size from SHT_PROGBITS section with index 3: unable to decode LEB128 at offset 0x00000008: malformed uleb128, extends past end
458 Content: "100000000000000080"
460 - Name: .stack_sizes (1)
462 Content: "100000000000000080"
471 ## Check that we report a warning when a relocation symbol does not belong to a
472 ## valid section or when it has an invalid index. We expect a stack size entry
473 ## with an unknown symbol in the output.
475 # RUN: yaml2obj --docnum=7 %s -o %t07
476 # RUN: llvm-readelf --stack-sizes %t07 2>&1 | \
477 # RUN: FileCheck %s -DFILE=%t07 --check-prefix=BADSECTION-OUT-GNU --implicit-check-not=warning:
478 # RUN: llvm-readobj --stack-sizes %t07 2>&1 | \
479 # RUN: FileCheck %s -DFILE=%t07 --check-prefix=BADSECTION-OUT-LLVM --implicit-check-not=warning:
481 # BADSECTION-OUT-GNU: Stack Sizes:
482 # BADSECTION-OUT-GNU-NEXT: Size Functions
483 # BADSECTION-OUT-GNU-NEXT: warning: '[[FILE]]': cannot identify the section for relocation symbol '_Z3foof': invalid section index: 10
484 # BADSECTION-OUT-GNU-NEXT: warning: '[[FILE]]': unable to get address of symbol '_Z3foof': invalid section index: 10
485 # BADSECTION-OUT-GNU-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 2
486 # BADSECTION-OUT-GNU-NEXT: 8 ?
487 # BADSECTION-OUT-GNU-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 1 in SHT_RELA section with index 3: unable to read an entry with index 255 from SHT_SYMTAB section with index 4: can't read an entry at 0x17e8: it goes past the end of the section (0x30)
488 # BADSECTION-OUT-GNU-NEXT: 22 ?
489 # BADSECTION-OUT-GNU-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 2 in SHT_RELA section with index 3: unable to read an entry with index 255 from SHT_SYMTAB section with index 4: can't read an entry at 0x17e8: it goes past the end of the section (0x30)
490 # BADSECTION-OUT-GNU-NEXT: 36 ?
492 # BADSECTION-OUT-LLVM: StackSizes [
493 # BADSECTION-OUT-LLVM-NEXT: warning: '[[FILE]]': cannot identify the section for relocation symbol '_Z3foof': invalid section index: 10
494 # BADSECTION-OUT-LLVM-NEXT: warning: '[[FILE]]': unable to get address of symbol '_Z3foof': invalid section index: 10
495 # BADSECTION-OUT-LLVM-NEXT: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 2
496 # BADSECTION-OUT-LLVM-NEXT: Entry {
497 # BADSECTION-OUT-LLVM-NEXT: Functions: [?]
498 # BADSECTION-OUT-LLVM-NEXT: Size: 0x8
499 # BADSECTION-OUT-LLVM-NEXT: }
500 # BADSECTION-OUT-LLVM-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 1 in SHT_RELA section with index 3: unable to read an entry with index 255 from SHT_SYMTAB section with index 4: can't read an entry at 0x17e8: it goes past the end of the section (0x30)
501 # BADSECTION-OUT-LLVM-NEXT: Entry {
502 # BADSECTION-OUT-LLVM-NEXT: Functions: [?]
503 # BADSECTION-OUT-LLVM-NEXT: Size: 0x16
504 # BADSECTION-OUT-LLVM-NEXT: }
505 # BADSECTION-OUT-LLVM-NEXT: warning: '[[FILE]]': unable to get the target of relocation with index 2 in SHT_RELA section with index 3: unable to read an entry with index 255 from SHT_SYMTAB section with index 4: can't read an entry at 0x17e8: it goes past the end of the section (0x30)
506 # BADSECTION-OUT-LLVM-NEXT: Entry {
507 # BADSECTION-OUT-LLVM-NEXT: Functions: [?]
508 # BADSECTION-OUT-LLVM-NEXT: Size: 0x24
509 # BADSECTION-OUT-LLVM-NEXT: }
510 # BADSECTION-OUT-LLVM-NEXT: ]
512 # RUN: llvm-readelf --stack-sizes --demangle %t07 2>&1 | FileCheck %s --check-prefix=BADSECTION-DEMANGLE-ERR -DFILE=%t07
513 # RUN: llvm-readobj --stack-sizes --demangle %t07 2>&1 | FileCheck %s --check-prefix=BADSECTION-DEMANGLE-ERR -DFILE=%t07
515 # BADSECTION-DEMANGLE-ERR: warning: '[[FILE]]': cannot identify the section for relocation symbol 'foo(float)'
534 - Name: .rela.stack_sizes
542 ## An invalid symbol index.
545 ## One more invalid symbol index with the same symbol value (0xff).
551 ## An invalid section index.
556 ## Check that we report a warning when a stack sizes section does not come with
557 ## a corresponding relocation section.
559 # RUN: yaml2obj --docnum=8 %s -o %t08
560 # RUN: llvm-readelf --stack-sizes %t08 2> %t08-gnu.err | FileCheck %s --check-prefix=NORELOCSECTION-OUT-GNU
561 # RUN: FileCheck %s < %t08-gnu.err --check-prefix=NORELOCSECTION-ERR -DFILE=%t08
562 # RUN: llvm-readobj --stack-sizes %t08 2> %t08-llvm.err | FileCheck %s --check-prefix=NORELOCSECTION-OUT-LLVM
563 # RUN: FileCheck %s < %t08-llvm.err --check-prefix=NORELOCSECTION-ERR -DFILE=%t08
565 # NORELOCSECTION-OUT-GNU: Size Functions
566 # NORELOCSECTION-OUT-GNU-NOT: {{.}}
568 # NORELOCSECTION-OUT-LLVM: StackSizes [
569 # NORELOCSECTION-OUT-LLVM-NEXT: ]
571 # NORELOCSECTION-ERR: warning: '[[FILE]]': .stack_sizes (SHT_PROGBITS section with index 2) does not have a corresponding relocation section
588 ## Check that we handle multiple object files, separately and when they
589 ## are in an archive. This also checks whether we have blank lines between the
592 # RUN: llvm-ar rc %t1.a %t01 %t02
593 # RUN: llvm-readelf --stack-sizes %t01 %t02 \
594 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-GNU,OBJECT -DFILE1=%t01 -DFILE2=%t02
595 # RUN: llvm-readelf --stack-sizes %t1.a \
596 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-GNU,ARCHIVE --strict-whitespace\
597 # RUN: --match-full-lines -DFILE=%t1.a
598 # RUN: llvm-readobj --stack-sizes %t01 %t02 \
599 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-LLVM,OBJECT -DFILE1=%t01 -DFILE2=%t02
600 # RUN: llvm-readobj --stack-sizes %t1.a \
601 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-LLVM,ARCHIVE -DFILE=%t1.a
603 # OBJECT:File: [[FILE1]]
604 # ARCHIVE:File: [[FILE]]({{.*01}})
606 # MULTIPLE-GNU:Stack Sizes:
607 # MULTIPLE-GNU-NEXT: Size Functions
608 # MULTIPLE-GNU-NEXT: 16 referenced_by_symbol_foo
609 # MULTIPLE-GNU-NEXT: 32 referenced_via_section_bar
610 # MULTIPLE-GNU-NEXT: 8 separate_text_section_baz
611 # MULTIPLE-GNU-EMPTY:
613 # MULTIPLE-LLVM: StackSizes [
614 # MULTIPLE-LLVM-NEXT: Entry {
615 # MULTIPLE-LLVM-NEXT: Functions: [referenced_by_symbol_foo]
616 # MULTIPLE-LLVM-NEXT: Size: 0x10
617 # MULTIPLE-LLVM-NEXT: }
618 # MULTIPLE-LLVM-NEXT: Entry {
619 # MULTIPLE-LLVM-NEXT: Functions: [referenced_via_section_bar]
620 # MULTIPLE-LLVM-NEXT: Size: 0x20
621 # MULTIPLE-LLVM-NEXT: }
622 # MULTIPLE-LLVM-NEXT: Entry {
623 # MULTIPLE-LLVM-NEXT: Functions: [separate_text_section_baz]
624 # MULTIPLE-LLVM-NEXT: Size: 0x8
625 # MULTIPLE-LLVM-NEXT: }
626 # MULTIPLE-LLVM-NEXT: ]
628 # OBJECT:File: [[FILE2]]
629 # ARCHIVE:File: [[FILE]]({{.*02}})
631 # MULTIPLE-GNU-EMPTY:
632 # MULTIPLE-GNU-NEXT:Stack Sizes:
633 # MULTIPLE-GNU-NEXT: Size Functions
634 # MULTIPLE-GNU-NEXT: 16 other
635 # MULTIPLE-GNU-NEXT: 32 other_end
636 # MULTIPLE-GNU-NEXT: 48 bar
638 # MULTIPLE-LLVM: StackSizes [
639 # MULTIPLE-LLVM-NEXT: Entry {
640 # MULTIPLE-LLVM-NEXT: Functions: [other]
641 # MULTIPLE-LLVM-NEXT: Size: 0x10
642 # MULTIPLE-LLVM-NEXT: }
643 # MULTIPLE-LLVM-NEXT: Entry {
644 # MULTIPLE-LLVM-NEXT: Functions: [other_end]
645 # MULTIPLE-LLVM-NEXT: Size: 0x20
646 # MULTIPLE-LLVM-NEXT: }
647 # MULTIPLE-LLVM-NEXT: Entry {
648 # MULTIPLE-LLVM-NEXT: Functions: [bar]
649 # MULTIPLE-LLVM-NEXT: Size: 0x30
650 # MULTIPLE-LLVM-NEXT: }
651 # MULTIPLE-LLVM-NEXT: ]
653 ## Check that we do not consider symbols that are not function symbols, even though
654 ## a relocation references them.
656 # RUN: yaml2obj --docnum=9 %s -o %t14
657 # RUN: llvm-readelf --stack-sizes %t14 2> %t14-gnu.err | FileCheck %s --check-prefix=NONFUNCTIONSYM-GNU
658 # RUN: FileCheck %s < %t14-gnu.err --check-prefix=NONFUNCTIONSYM-ERR -DFILE=%t14
659 # RUN: llvm-readobj --stack-sizes %t14 2> %t14-llvm.err | FileCheck %s --check-prefix=NONFUNCTIONSYM-LLVM
660 # RUN: FileCheck %s < %t14-llvm.err --check-prefix=NONFUNCTIONSYM-ERR -DFILE=%t14
662 # NONFUNCTIONSYM-GNU: Stack Sizes:
663 # NONFUNCTIONSYM-GNU: 0 ?
665 # NONFUNCTIONSYM-LLVM: StackSizes [
666 # NONFUNCTIONSYM-LLVM-NEXT: Entry {
667 # NONFUNCTIONSYM-LLVM-NEXT: Functions: [?]
668 # NONFUNCTIONSYM-LLVM-NEXT: Size: 0x0
669 # NONFUNCTIONSYM-LLVM-NEXT: }
670 # NONFUNCTIONSYM-LLVM-NEXT: ]
672 # NONFUNCTIONSYM-ERR: warning: '[[FILE]]': could not identify function symbol for stack size entry in SHT_PROGBITS section with index 2
689 - Name: .rela.stack_sizes
702 ## Check that we report a warning when we find an unsupported relocation
703 ## in the section that contains the stack size entries' relocations.
705 # RUN: yaml2obj --docnum=10 %s -o %t15
706 # RUN: llvm-readelf --stack-sizes %t15 2>&1 | FileCheck %s --check-prefix=UNSUPPRELOC-GNU -DFILE=%t15
707 # RUN: llvm-readobj --stack-sizes %t15 2>&1 | FileCheck %s --check-prefix=UNSUPPRELOC-LLVM -DFILE=%t15
709 # UNSUPPRELOC-GNU: Stack Sizes:
710 # UNSUPPRELOC-GNU-NEXT: Size Functions
711 # UNSUPPRELOC-GNU-NEXT: warning: '[[FILE]]': SHT_RELA section with index 3 contains an unsupported relocation with index 0: R_X86_64_RELATIVE
712 # UNSUPPRELOC-GNU-NEXT: 0 foo
713 # UNSUPPRELOC-GNU-NEXT: warning: '[[FILE]]': SHT_RELA section with index 3 contains an unsupported relocation with index 2: R_X86_64_RELATIVE
715 # UNSUPPRELOC-LLVM: StackSizes [
716 # UNSUPPRELOC-LLVM-NEXT: warning: '[[FILE]]': SHT_RELA section with index 3 contains an unsupported relocation with index 0: R_X86_64_RELATIVE
717 # UNSUPPRELOC-LLVM-NEXT: Entry {
718 # UNSUPPRELOC-LLVM-NEXT: Functions: [foo]
719 # UNSUPPRELOC-LLVM-NEXT: Size: 0x0
720 # UNSUPPRELOC-LLVM-NEXT: }
721 # UNSUPPRELOC-LLVM-NEXT: warning: '[[FILE]]': SHT_RELA section with index 3 contains an unsupported relocation with index 2: R_X86_64_RELATIVE
722 # UNSUPPRELOC-LLVM-NEXT: ]
739 - Name: .rela.stack_sizes
745 Type: R_X86_64_RELATIVE
751 Type: R_X86_64_RELATIVE
758 ## Check that warning messages in archives do not impact other members. In the following
759 ## test, the first archive member generates a warning and we make sure all the information
762 # RUN: llvm-ar rc %t2.a %t04 %t01
763 # RUN: llvm-readelf --stack-sizes %t2.a 2>&1 | FileCheck %s --check-prefix=ARCHIVEWARN-GNU \
764 # RUN: -DFILE=%t2.a --strict-whitespace --match-full-lines
765 # RUN: llvm-readobj --stack-sizes %t2.a 2>&1 | FileCheck %s --check-prefix=ARCHIVEWARN-LLVM -DFILE=%t2.a
767 # ARCHIVEWARN-GNU:File: [[FILE]]({{.*04}})
768 # ARCHIVEWARN-GNU:Stack Sizes:
769 # ARCHIVEWARN-GNU-NEXT: Size Functions
770 # ARCHIVEWARN-GNU:{{.*}}: warning: '{{.*04}}': relocation symbol '_Z3foof' is not in the expected section
771 # ARCHIVEWARN-GNU: 8 _Z3foof
772 # ARCHIVEWARN-GNU:File: [[FILE]]({{.*01}})
773 # ARCHIVEWARN-GNU:Stack Sizes:
774 # ARCHIVEWARN-GNU-NEXT: Size Functions
775 # ARCHIVEWARN-GNU-NEXT: 16 referenced_by_symbol_foo
776 # ARCHIVEWARN-GNU-NEXT: 32 referenced_via_section_bar
777 # ARCHIVEWARN-GNU-NEXT: 8 separate_text_section_baz
778 # ARCHIVEWARN-GNU-NOT:{{.}}
781 # ARCHIVEWARN-LLVM: File: [[FILE]]({{.*04}})
782 # ARCHIVEWARN-LLVM: StackSizes [
783 # ARCHIVEWARN-LLVM: warning: '{{.*04}}': relocation symbol '_Z3foof' is not in the expected section
784 # ARCHIVEWARN-LLVM-NEXT: Entry {
785 # ARCHIVEWARN-LLVM-NEXT: Functions: [_Z3foof]
786 # ARCHIVEWARN-LLVM-NEXT: Size: 0x8
787 # ARCHIVEWARN-LLVM-NEXT: }
788 # ARCHIVEWARN-LLVM-NEXT: ]
789 # ARCHIVEWARN-LLVM: File: [[FILE]]({{.*01}})
790 # ARCHIVEWARN-LLVM: StackSizes [
791 # ARCHIVEWARN-LLVM-NEXT: Entry {
792 # ARCHIVEWARN-LLVM-NEXT: Functions: [referenced_by_symbol_foo]
793 # ARCHIVEWARN-LLVM-NEXT: Size: 0x10
794 # ARCHIVEWARN-LLVM-NEXT: }
795 # ARCHIVEWARN-LLVM-NEXT: Entry {
796 # ARCHIVEWARN-LLVM-NEXT: Functions: [referenced_via_section_bar]
797 # ARCHIVEWARN-LLVM-NEXT: Size: 0x20
798 # ARCHIVEWARN-LLVM-NEXT: }
799 # ARCHIVEWARN-LLVM-NEXT: Entry {
800 # ARCHIVEWARN-LLVM-NEXT: Functions: [separate_text_section_baz]
801 # ARCHIVEWARN-LLVM-NEXT: Size: 0x8
802 # ARCHIVEWARN-LLVM-NEXT: }
803 # ARCHIVEWARN-LLVM-NEXT: ]
805 ## Check that we demangle function names when requested.
807 # RUN: yaml2obj --docnum=11 %s -o %t16
808 # RUN: llvm-readelf --stack-sizes --demangle %t16 | FileCheck %s --check-prefix=DEMANGLE-GNU
809 # RUN: llvm-readobj --stack-sizes --demangle %t16 | FileCheck %s --check-prefix=DEMANGLE-LLVM
811 # DEMANGLE-GNU: 16 foo(float)
812 # DEMANGLE-LLVM: Functions: [foo(float)]
837 ## Check that we report a warning when we are unable to resolve a relocation for a given ELF architecture.
838 ## Here we have a 64-bit relocation used in a 32-bit object.
840 # RUN: yaml2obj --docnum=12 %s -o %t17
841 # RUN: llvm-readelf --stack-sizes %t17 2>&1 | FileCheck %s -DFILE=%t17 --check-prefix=UNSUPPRELOC2
842 # RUN: llvm-readobj --stack-sizes %t17 2>&1 | FileCheck %s -DFILE=%t17 --check-prefix=UNSUPPRELOC2
844 # UNSUPPRELOC2: warning: '[[FILE]]': SHT_RELA section with index 2 contains an unsupported relocation with index 0: R_X86_64_64
856 - Name: .rela.stack_sizes
863 ## Check we report a warning when dumping stack sizes if the relocated section
864 ## identified by the sh_info field is invalid. Here the sh_info value is larger than
865 ## the number of sections.
867 # RUN: yaml2obj --docnum=13 %s -o %t18
868 # RUN: llvm-readelf --stack-sizes %t18 2>&1 | \
869 # RUN: FileCheck %s --implicit-check-not="warning:" -DFILE=%t18 --check-prefix=INVALID-TARGET
870 # RUN: llvm-readobj --stack-sizes %t18 2>&1 | \
871 # RUN: FileCheck %s --implicit-check-not="warning:" -DFILE=%t18 --check-prefix=INVALID-TARGET
873 # INVALID-TARGET: warning: '[[FILE]]': unable to get stack size map section(s): SHT_RELA section with index 1: failed to get a relocated section: invalid section index: 255
874 # INVALID-TARGET: SHT_RELA section with index 2: failed to get a relocated section: invalid section index: 255
882 - Name: .rela.stack_sizes
887 - Name: .rela.stack_sizes (1)
893 ## Check that that we see multiple symbols output in cases when multiple symbols
894 ## share the same stack size entry, for example when use of ICF means two functions
895 ## are represented by the same code.
897 # RUN: yaml2obj --docnum=14 %s -o %t19
898 # RUN: llvm-readelf --stack-sizes %t19 2>&1 \
899 # RUN: | FileCheck %s --check-prefix=MULTIPLE-SYMBOLS-GNU
900 # RUN: llvm-readobj --stack-sizes %t19 2>&1 \
901 # RUN: | FileCheck %s --check-prefix=MULTIPLE-SYMBOLS-LLVM
903 # MULTIPLE-SYMBOLS-GNU: Size Functions
904 # MULTIPLE-SYMBOLS-GNU: 16 foo, bar
905 # MULTIPLE-SYMBOLS-GNU-NOT:{{.}}
907 # MULTIPLE-SYMBOLS-LLVM: StackSizes [
908 # MULTIPLE-SYMBOLS-LLVM-NEXT: Entry {
909 # MULTIPLE-SYMBOLS-LLVM-NEXT: Functions: [foo, bar]
910 # MULTIPLE-SYMBOLS-LLVM-NEXT: Size: 0x10
911 # MULTIPLE-SYMBOLS-LLVM-NEXT: }
912 # MULTIPLE-SYMBOLS-LLVM-NEXT: ]
913 # MULTIPLE-SYMBOLS-LLVM-NOT:{{.}}