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 > %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 Function
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: Function: referenced_by_symbol_foo
18 # RELOC-LLVM-NEXT: Size: 0x10
20 # RELOC-LLVM-NEXT: Entry {
21 # RELOC-LLVM-NEXT: Function: referenced_via_section_bar
22 # RELOC-LLVM-NEXT: Size: 0x20
24 # RELOC-LLVM-NEXT: Entry {
25 # RELOC-LLVM-NEXT: Function: separate_text_section_baz
26 # RELOC-LLVM-NEXT: Size: 0x8
47 ## 2 stack size entries. Each consists of an address (subject to relocation)
48 ## followed by a ULEB for the size.
49 Content: "000000000000000010000000000000000020"
51 - Name: '.stack_sizes [1]'
53 ## One stack size entry.
54 Content: "200000000000000008"
56 - Name: .rela.stack_sizes
60 ## A symbol relative reference.
62 Symbol: referenced_by_symbol_foo
64 ## A section relative reference.
69 - Name: '.rela.stack_sizes [1]'
71 Info: '.stack_sizes [1]'
74 Symbol: separate_text_section_baz
77 - Name: separate_text_section_baz
83 - Name: referenced_by_symbol_foo
87 - Name: referenced_via_section_bar
93 ## Check that we correctly report the stack sizes in an executable (non-relocatable)
96 # RUN: yaml2obj --docnum=2 %s > %t02
97 # RUN: llvm-readelf --stack-sizes %t02 \
98 # RUN: | FileCheck %s --check-prefix=EXEC-GNU --strict-whitespace --match-full-lines
99 # RUN: llvm-readobj --stack-sizes %t02 | FileCheck %s --check-prefix=EXEC-LLVM
101 # EXEC-GNU: Size Function
102 # EXEC-GNU-NEXT: 16 foo
103 # EXEC-GNU-NEXT: 32 bar
106 # EXEC-LLVM: StackSizes [
107 # EXEC-LLVM-NEXT: Entry {
108 # EXEC-LLVM-NEXT: Function: foo
109 # EXEC-LLVM-NEXT: Size: 0x10
111 # EXEC-LLVM-NEXT: Entry {
112 # EXEC-LLVM-NEXT: Function: bar
113 # EXEC-LLVM-NEXT: Size: 0x20
130 Content: "100000000000000010200000000000000020"
144 ## Check that we report an error when we find relocations whose offsets point outside
145 ## of the .stack_sizes section.
147 # RUN: yaml2obj --docnum=3 %s > %t03
148 # RUN: not llvm-readelf --stack-sizes %t03 2>&1 | FileCheck %s --check-prefix=SHORT -DFILE=%t03
149 # RUN: not llvm-readobj --stack-sizes %t03 2>&1 | FileCheck %s --check-prefix=SHORT -DFILE=%t03
151 # SHORT: error: '[[FILE]]': found invalid relocation offset into section .stack_sizes while trying to extract a stack size entry
168 - Name: .rela.stack_sizes
181 ## Check that we warn about a function symbol that is not in the section
182 ## that is referenced by the stack sizes section's sh_link.
184 # RUN: yaml2obj --docnum=4 %s > %t04
185 # RUN: llvm-readelf --stack-sizes %t04 2> %t04-gnu.err | FileCheck %s --check-prefix=WRONGSECTION-GNU
186 # RUN: FileCheck %s < %t04-gnu.err --check-prefix=WRONGSECTION-ERR -DFILE=%t04
187 # RUN: llvm-readobj --stack-sizes %t04 2> %t04-llvm.err | FileCheck %s --check-prefix=WRONGSECTION-LLVM
188 # RUN: FileCheck %s < %t04-llvm.err --check-prefix=WRONGSECTION-ERR -DFILE=%t04
190 # WRONGSECTION-GNU: Size Function
191 # WRONGSECTION-GNU-NEXT: 8 foo
193 # WRONGSECTION-LLVM: StackSizes [
194 # WRONGSECTION-LLVM-NEXT: Entry {
195 # WRONGSECTION-LLVM-NEXT: Function: foo
196 # WRONGSECTION-LLVM-NEXT: Size: 0x8
197 # WRONGSECTION-LLVM-NEXT: }
198 # WRONGSECTION-LLVM-NEXT: ]
200 # WRONGSECTION-ERR: warning: '[[FILE]]': relocation symbol foo is not in the expected section
218 Content: "000000000000000008"
220 - Name: .rela.stack_sizes
233 ## Check that we report an error when a stack sizes section ends with an incomplete stack size entry.
235 # RUN: yaml2obj --docnum=5 %s > %t05
236 # RUN: not llvm-readelf --stack-sizes %t05 2>&1 | \
237 # RUN: FileCheck %s --check-prefix=SUDDENEND -DFILE=%t05
238 # RUN: not llvm-readobj --stack-sizes %t05 2>&1 | \
239 # RUN: FileCheck %s --check-prefix=SUDDENEND -DFILE=%t05
241 # SUDDENEND: error: '[[FILE]]': section .stack_sizes ended while trying to extract a stack size entry
265 ## Check that we report an invalid stack size, which is represented by a ULEB that
266 ## ends in a byte with the high bit set.
268 # RUN: yaml2obj --docnum=6 %s > %t06
269 # RUN: not llvm-readelf --stack-sizes %t06 2>&1 | FileCheck %s --check-prefix=BADSIZE -DFILE=%t06
270 # RUN: not llvm-readobj --stack-sizes %t06 2>&1 | FileCheck %s --check-prefix=BADSIZE -DFILE=%t06
272 # BADSIZE: error: '[[FILE]]': could not extract a valid stack size in section .stack_sizes
287 Content: "100000000000000080"
296 ## Check that we report a warning when a relocation symbol does not belong to a
297 ## valid section. We expect a stack size entry with an unknown symbol in the
300 # RUN: yaml2obj --docnum=7 %s > %t07
301 # RUN: llvm-readelf --stack-sizes %t07 2> %t07-gnu.err | FileCheck %s --check-prefix=BADSECTION-OUT-GNU
302 # RUN: FileCheck %s < %t07-gnu.err --check-prefix=BADSECTION-ERR -DFILE=%t07
303 # RUN: llvm-readobj --stack-sizes %t07 2> %t07-llvm.err | FileCheck %s --check-prefix=BADSECTION-OUT-LLVM
304 # RUN: FileCheck %s < %t07-llvm.err --check-prefix=BADSECTION-ERR -DFILE=%t07
306 # BADSECTION-OUT-GNU: Size Function
307 # BADSECTION-OUT-GNU: 8 ?
309 # BADSECTION-OUT-LLVM: StackSizes [
310 # BADSECTION-OUT-LLVM-NEXT: Entry {
311 # BADSECTION-OUT-LLVM-NEXT: Function: ?
312 # BADSECTION-OUT-LLVM-NEXT: Size: 0x8
313 # BADSECTION-OUT-LLVM-NEXT: }
314 # BADSECTION-OUT-LLVM-NEXT: ]
316 # BADSECTION-ERR: warning: '[[FILE]]': cannot identify the section for relocation symbol foo
331 Content: "000000000000000008"
332 - Name: .rela.stack_sizes
341 ## An invalid section index.
346 ## Check that we report a warning when a stack sizes section does not come with
347 ## a corresponding relocation section.
349 # RUN: yaml2obj --docnum=8 %s > %t08
350 # RUN: llvm-readelf --stack-sizes %t08 2> %t08-gnu.err | FileCheck %s --check-prefix=NORELOCSECTION-OUT-GNU
351 # RUN: FileCheck %s < %t08-gnu.err --check-prefix=NORELOCSECTION-ERR -DFILE=%t08
352 # RUN: llvm-readobj --stack-sizes %t08 2> %t08-llvm.err | FileCheck %s --check-prefix=NORELOCSECTION-OUT-LLVM
353 # RUN: FileCheck %s < %t08-llvm.err --check-prefix=NORELOCSECTION-ERR -DFILE=%t08
355 # NORELOCSECTION-OUT-GNU: Size Function
356 # NORELOCSECTION-OUT-GNU-NOT: {{.}}
358 # NORELOCSECTION-OUT-LLVM: StackSizes [
359 # NORELOCSECTION-OUT-LLVM-NEXT: ]
361 # NORELOCSECTION-ERR: warning: '[[FILE]]': section .stack_sizes does not have a corresponding relocation section
376 Content: "000000000000000008"
378 ## Check that we handle multiple object files, separately and when they
379 ## are in an archive. This also checks whether we have blank lines between the
382 # RUN: llvm-ar rc %t1.a %t01 %t02
383 # RUN: llvm-readelf --stack-sizes %t01 %t02 \
384 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-GNU,OBJECT -DFILE1=%t01 -DFILE2=%t02
385 # RUN: llvm-readelf --stack-sizes %t1.a \
386 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-GNU,ARCHIVE --strict-whitespace\
387 # RUN: --match-full-lines -DFILE=%t1.a
388 # RUN: llvm-readobj --stack-sizes %t01 %t02 \
389 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-LLVM,OBJECT -DFILE1=%t01 -DFILE2=%t02
390 # RUN: llvm-readobj --stack-sizes %t1.a \
391 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-LLVM,ARCHIVE -DFILE=%t1.a
393 # OBJECT:File: [[FILE1]]
394 # ARCHIVE:File: [[FILE]]({{.*01}})
396 # MULTIPLE-GNU:Stack Sizes:
397 # MULTIPLE-GNU-NEXT: Size Function
398 # MULTIPLE-GNU-NEXT: 16 referenced_by_symbol_foo
399 # MULTIPLE-GNU-NEXT: 32 referenced_via_section_bar
400 # MULTIPLE-GNU-NEXT: 8 separate_text_section_baz
401 # MULTIPLE-GNU-EMPTY:
403 # MULTIPLE-LLVM: StackSizes [
404 # MULTIPLE-LLVM-NEXT: Entry {
405 # MULTIPLE-LLVM-NEXT: Function: referenced_by_symbol_foo
406 # MULTIPLE-LLVM-NEXT: Size: 0x10
407 # MULTIPLE-LLVM-NEXT: }
408 # MULTIPLE-LLVM-NEXT: Entry {
409 # MULTIPLE-LLVM-NEXT: Function: referenced_via_section_bar
410 # MULTIPLE-LLVM-NEXT: Size: 0x20
411 # MULTIPLE-LLVM-NEXT: }
412 # MULTIPLE-LLVM-NEXT: Entry {
413 # MULTIPLE-LLVM-NEXT: Function: separate_text_section_baz
414 # MULTIPLE-LLVM-NEXT: Size: 0x8
415 # MULTIPLE-LLVM-NEXT: }
416 # MULTIPLE-LLVM-NEXT: ]
418 # OBJECT:File: [[FILE2]]
419 # ARCHIVE:File: [[FILE]]({{.*02}})
421 # MULTIPLE-GNU-EMPTY:
422 # MULTIPLE-GNU-NEXT:Stack Sizes:
423 # MULTIPLE-GNU-NEXT: Size Function
424 # MULTIPLE-GNU-NEXT: 16 foo
425 # MULTIPLE-GNU-NEXT: 32 bar
427 # MULTIPLE-LLVM: StackSizes [
428 # MULTIPLE-LLVM-NEXT: Entry {
429 # MULTIPLE-LLVM-NEXT: Function: foo
430 # MULTIPLE-LLVM-NEXT: Size: 0x10
431 # MULTIPLE-LLVM-NEXT: }
432 # MULTIPLE-LLVM-NEXT: Entry {
433 # MULTIPLE-LLVM-NEXT: Function: bar
434 # MULTIPLE-LLVM-NEXT: Size: 0x20
435 # MULTIPLE-LLVM-NEXT: }
436 # MULTIPLE-LLVM-NEXT: ]
438 ## Check that we do not consider symbols that are not function symbols, even though
439 ## a relocation references them.
441 # RUN: yaml2obj --docnum=9 %s > %t14
442 # RUN: llvm-readelf --stack-sizes %t14 2> %t14-gnu.err | FileCheck %s --check-prefix=NONFUNCTIONSYM-GNU
443 # RUN: FileCheck %s < %t14-gnu.err --check-prefix=NONFUNCTIONSYM-ERR -DFILE=%t14
444 # RUN: llvm-readobj --stack-sizes %t14 2> %t14-llvm.err | FileCheck %s --check-prefix=NONFUNCTIONSYM-LLVM
445 # RUN: FileCheck %s < %t14-llvm.err --check-prefix=NONFUNCTIONSYM-ERR -DFILE=%t14
447 # NONFUNCTIONSYM-GNU: Stack Sizes:
448 # NONFUNCTIONSYM-GNU: 0 ?
450 # NONFUNCTIONSYM-LLVM: StackSizes [
451 # NONFUNCTIONSYM-LLVM-NEXT: Entry {
452 # NONFUNCTIONSYM-LLVM-NEXT: Function: ?
453 # NONFUNCTIONSYM-LLVM-NEXT: Size: 0x0
454 # NONFUNCTIONSYM-LLVM-NEXT: }
455 # NONFUNCTIONSYM-LLVM-NEXT: ]
457 # NONFUNCTIONSYM-ERR: warning: '[[FILE]]': could not identify function symbol for stack size entry
473 - Name: .rela.stack_sizes
486 ## Check that we report an error when we find an unsupported relocation
487 ## in the section that contains the stack size entries' relocations.
489 # RUN: yaml2obj --docnum=10 %s > %t15
490 # RUN: not llvm-readelf --stack-sizes %t15 2>&1 | FileCheck %s --check-prefix=UNSUPPRELOC -DFILE=%t15
491 # RUN: not llvm-readobj --stack-sizes %t15 2>&1 | FileCheck %s --check-prefix=UNSUPPRELOC -DFILE=%t15
493 # UNSUPPRELOC: error: '[[FILE]]': unsupported relocation type in section .rela.stack_sizes: R_X86_64_RELATIVE
509 - Name: .rela.stack_sizes
515 Type: R_X86_64_RELATIVE
522 ## Check that warning messages in archives do not impact other members. In the following
523 ## test, the first archive member generates a warning and we make sure all the information
526 # RUN: llvm-ar rc %t2.a %t04 %t01
527 # RUN: llvm-readelf --stack-sizes %t2.a 2>&1 | FileCheck %s --check-prefix=ARCHIVEWARN-GNU \
528 # RUN: -DFILE=%t2.a --strict-whitespace --match-full-lines
529 # RUN: llvm-readobj --stack-sizes %t2.a 2>&1 | FileCheck %s --check-prefix=ARCHIVEWARN-LLVM -DFILE=%t2.a
531 # ARCHIVEWARN-GNU:File: [[FILE]]({{.*04}})
532 # ARCHIVEWARN-GNU:Stack Sizes:
533 # ARCHIVEWARN-GNU-NEXT: Size Function
534 # ARCHIVEWARN-GNU:{{.*}}: warning: '{{.*04}}': relocation symbol foo is not in the expected section
535 # ARCHIVEWARN-GNU: 8 foo
536 # ARCHIVEWARN-GNU:File: [[FILE]]({{.*01}})
537 # ARCHIVEWARN-GNU:Stack Sizes:
538 # ARCHIVEWARN-GNU-NEXT: Size Function
539 # ARCHIVEWARN-GNU-NEXT: 16 referenced_by_symbol_foo
540 # ARCHIVEWARN-GNU-NEXT: 32 referenced_via_section_bar
541 # ARCHIVEWARN-GNU-NEXT: 8 separate_text_section_baz
542 # ARCHIVEWARN-GNU-NOT:{{.}}
545 # ARCHIVEWARN-LLVM: File: [[FILE]]({{.*04}})
546 # ARCHIVEWARN-LLVM: StackSizes [
547 # ARCHIVEWARN-LLVM: warning: '{{.*04}}': relocation symbol foo is not in the expected section
548 # ARCHIVEWARN-LLVM-NEXT: Entry {
549 # ARCHIVEWARN-LLVM-NEXT: Function: foo
550 # ARCHIVEWARN-LLVM-NEXT: Size: 0x8
551 # ARCHIVEWARN-LLVM-NEXT: }
552 # ARCHIVEWARN-LLVM-NEXT: ]
553 # ARCHIVEWARN-LLVM: File: [[FILE]]({{.*01}})
554 # ARCHIVEWARN-LLVM: StackSizes [
555 # ARCHIVEWARN-LLVM-NEXT: Entry {
556 # ARCHIVEWARN-LLVM-NEXT: Function: referenced_by_symbol_foo
557 # ARCHIVEWARN-LLVM-NEXT: Size: 0x10
558 # ARCHIVEWARN-LLVM-NEXT: }
559 # ARCHIVEWARN-LLVM-NEXT: Entry {
560 # ARCHIVEWARN-LLVM-NEXT: Function: referenced_via_section_bar
561 # ARCHIVEWARN-LLVM-NEXT: Size: 0x20
562 # ARCHIVEWARN-LLVM-NEXT: }
563 # ARCHIVEWARN-LLVM-NEXT: Entry {
564 # ARCHIVEWARN-LLVM-NEXT: Function: separate_text_section_baz
565 # ARCHIVEWARN-LLVM-NEXT: Size: 0x8
566 # ARCHIVEWARN-LLVM-NEXT: }
567 # ARCHIVEWARN-LLVM-NEXT: ]
569 ## Check that we demangle function names when requested.
571 # RUN: yaml2obj --docnum=11 %s > %t16
572 # RUN: llvm-readelf --stack-sizes --demangle %t16 | FileCheck %s --check-prefix=DEMANGLE-GNU
573 # RUN: llvm-readobj --stack-sizes --demangle %t16 | FileCheck %s --check-prefix=DEMANGLE-LLVM
575 # DEMANGLE-GNU: 16 foo(float)
576 # DEMANGLE-LLVM: Function: foo(float)
591 Content: "100000000000000010"