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
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
78 - Name: separate_text_section_baz
84 - Name: referenced_by_symbol_foo
88 - Name: referenced_via_section_bar
94 ## Check that we correctly report the stack sizes in an executable (non-relocatable)
97 # RUN: yaml2obj --docnum=2 %s > %t02
98 # RUN: llvm-readelf --stack-sizes %t02 \
99 # RUN: | FileCheck %s --check-prefix=EXEC-GNU --strict-whitespace --match-full-lines
100 # RUN: llvm-readobj --stack-sizes %t02 | FileCheck %s --check-prefix=EXEC-LLVM
102 # EXEC-GNU: Size Function
103 # EXEC-GNU-NEXT: 16 foo
104 # EXEC-GNU-NEXT: 32 bar
107 # EXEC-LLVM: StackSizes [
108 # EXEC-LLVM-NEXT: Entry {
109 # EXEC-LLVM-NEXT: Function: foo
110 # EXEC-LLVM-NEXT: Size: 0x10
112 # EXEC-LLVM-NEXT: Entry {
113 # EXEC-LLVM-NEXT: Function: bar
114 # EXEC-LLVM-NEXT: Size: 0x20
149 ## Check that we report an error when we find relocations whose offsets point outside
150 ## of the .stack_sizes section.
152 # RUN: yaml2obj --docnum=3 %s > %t03
153 # RUN: not llvm-readelf --stack-sizes %t03 2>&1 | FileCheck %s --check-prefix=SHORT -DFILE=%t03
154 # RUN: not llvm-readobj --stack-sizes %t03 2>&1 | FileCheck %s --check-prefix=SHORT -DFILE=%t03
156 # SHORT: error: '[[FILE]]': found invalid relocation offset into section .stack_sizes while trying to extract a stack size entry
173 - Name: .rela.stack_sizes
186 ## Check that we warn about a function symbol that is not in the section
187 ## that is referenced by the stack sizes section's sh_link.
189 # RUN: yaml2obj --docnum=4 %s > %t04
190 # RUN: llvm-readelf --stack-sizes %t04 2> %t04-gnu.err | FileCheck %s --check-prefix=WRONGSECTION-GNU
191 # RUN: FileCheck %s < %t04-gnu.err --check-prefix=WRONGSECTION-ERR -DFILE=%t04
192 # RUN: llvm-readobj --stack-sizes %t04 2> %t04-llvm.err | FileCheck %s --check-prefix=WRONGSECTION-LLVM
193 # RUN: FileCheck %s < %t04-llvm.err --check-prefix=WRONGSECTION-ERR -DFILE=%t04
195 # WRONGSECTION-GNU: Size Function
196 # WRONGSECTION-GNU-NEXT: 8 foo
198 # WRONGSECTION-LLVM: StackSizes [
199 # WRONGSECTION-LLVM-NEXT: Entry {
200 # WRONGSECTION-LLVM-NEXT: Function: foo
201 # WRONGSECTION-LLVM-NEXT: Size: 0x8
202 # WRONGSECTION-LLVM-NEXT: }
203 # WRONGSECTION-LLVM-NEXT: ]
205 # WRONGSECTION-ERR: warning: '[[FILE]]': relocation symbol foo is not in the expected section
226 - Name: .rela.stack_sizes
239 ## Check that we report an error when a stack sizes section ends with an incomplete stack size entry.
241 # RUN: yaml2obj --docnum=5 %s > %t05
242 # RUN: not llvm-readelf --stack-sizes %t05 2>&1 | \
243 # RUN: FileCheck %s --check-prefix=SUDDENEND -DFILE=%t05
244 # RUN: not llvm-readobj --stack-sizes %t05 2>&1 | \
245 # RUN: FileCheck %s --check-prefix=SUDDENEND -DFILE=%t05
247 # SUDDENEND: error: '[[FILE]]': section .stack_sizes ended while trying to extract a stack size entry
271 ## Check that we report an invalid stack size, which is represented by a ULEB that
272 ## ends in a byte with the high bit set.
274 # RUN: yaml2obj --docnum=6 %s > %t06
275 # RUN: not llvm-readelf --stack-sizes %t06 2>&1 | FileCheck %s --check-prefix=BADSIZE -DFILE=%t06
276 # RUN: not llvm-readobj --stack-sizes %t06 2>&1 | FileCheck %s --check-prefix=BADSIZE -DFILE=%t06
278 # BADSIZE: error: '[[FILE]]': could not extract a valid stack size in section .stack_sizes
293 Content: "100000000000000080"
302 ## Check that we report a warning when a relocation symbol does not belong to a
303 ## valid section. We expect a stack size entry with an unknown symbol in the
306 # RUN: yaml2obj --docnum=7 %s > %t07
307 # RUN: llvm-readelf --stack-sizes %t07 2> %t07-gnu.err | FileCheck %s --check-prefix=BADSECTION-OUT-GNU
308 # RUN: FileCheck %s < %t07-gnu.err --check-prefix=BADSECTION-ERR -DFILE=%t07
309 # RUN: llvm-readobj --stack-sizes %t07 2> %t07-llvm.err | FileCheck %s --check-prefix=BADSECTION-OUT-LLVM
310 # RUN: FileCheck %s < %t07-llvm.err --check-prefix=BADSECTION-ERR -DFILE=%t07
312 # BADSECTION-OUT-GNU: Size Function
313 # BADSECTION-OUT-GNU: 8 ?
315 # BADSECTION-OUT-LLVM: StackSizes [
316 # BADSECTION-OUT-LLVM-NEXT: Entry {
317 # BADSECTION-OUT-LLVM-NEXT: Function: ?
318 # BADSECTION-OUT-LLVM-NEXT: Size: 0x8
319 # BADSECTION-OUT-LLVM-NEXT: }
320 # BADSECTION-OUT-LLVM-NEXT: ]
322 # BADSECTION-ERR: warning: '[[FILE]]': cannot identify the section for relocation symbol foo
339 - Name: .rela.stack_sizes
348 ## An invalid section index.
353 ## Check that we report a warning when a stack sizes section does not come with
354 ## a corresponding relocation section.
356 # RUN: yaml2obj --docnum=8 %s > %t08
357 # RUN: llvm-readelf --stack-sizes %t08 2> %t08-gnu.err | FileCheck %s --check-prefix=NORELOCSECTION-OUT-GNU
358 # RUN: FileCheck %s < %t08-gnu.err --check-prefix=NORELOCSECTION-ERR -DFILE=%t08
359 # RUN: llvm-readobj --stack-sizes %t08 2> %t08-llvm.err | FileCheck %s --check-prefix=NORELOCSECTION-OUT-LLVM
360 # RUN: FileCheck %s < %t08-llvm.err --check-prefix=NORELOCSECTION-ERR -DFILE=%t08
362 # NORELOCSECTION-OUT-GNU: Size Function
363 # NORELOCSECTION-OUT-GNU-NOT: {{.}}
365 # NORELOCSECTION-OUT-LLVM: StackSizes [
366 # NORELOCSECTION-OUT-LLVM-NEXT: ]
368 # NORELOCSECTION-ERR: warning: '[[FILE]]': section .stack_sizes does not have a corresponding relocation section
386 ## Check that we handle multiple object files, separately and when they
387 ## are in an archive. This also checks whether we have blank lines between the
390 # RUN: llvm-ar rc %t1.a %t01 %t02
391 # RUN: llvm-readelf --stack-sizes %t01 %t02 \
392 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-GNU,OBJECT -DFILE1=%t01 -DFILE2=%t02
393 # RUN: llvm-readelf --stack-sizes %t1.a \
394 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-GNU,ARCHIVE --strict-whitespace\
395 # RUN: --match-full-lines -DFILE=%t1.a
396 # RUN: llvm-readobj --stack-sizes %t01 %t02 \
397 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-LLVM,OBJECT -DFILE1=%t01 -DFILE2=%t02
398 # RUN: llvm-readobj --stack-sizes %t1.a \
399 # RUN: | FileCheck %s --check-prefixes=MULTIPLE-LLVM,ARCHIVE -DFILE=%t1.a
401 # OBJECT:File: [[FILE1]]
402 # ARCHIVE:File: [[FILE]]({{.*01}})
404 # MULTIPLE-GNU:Stack Sizes:
405 # MULTIPLE-GNU-NEXT: Size Function
406 # MULTIPLE-GNU-NEXT: 16 referenced_by_symbol_foo
407 # MULTIPLE-GNU-NEXT: 32 referenced_via_section_bar
408 # MULTIPLE-GNU-NEXT: 8 separate_text_section_baz
409 # MULTIPLE-GNU-EMPTY:
411 # MULTIPLE-LLVM: StackSizes [
412 # MULTIPLE-LLVM-NEXT: Entry {
413 # MULTIPLE-LLVM-NEXT: Function: referenced_by_symbol_foo
414 # MULTIPLE-LLVM-NEXT: Size: 0x10
415 # MULTIPLE-LLVM-NEXT: }
416 # MULTIPLE-LLVM-NEXT: Entry {
417 # MULTIPLE-LLVM-NEXT: Function: referenced_via_section_bar
418 # MULTIPLE-LLVM-NEXT: Size: 0x20
419 # MULTIPLE-LLVM-NEXT: }
420 # MULTIPLE-LLVM-NEXT: Entry {
421 # MULTIPLE-LLVM-NEXT: Function: separate_text_section_baz
422 # MULTIPLE-LLVM-NEXT: Size: 0x8
423 # MULTIPLE-LLVM-NEXT: }
424 # MULTIPLE-LLVM-NEXT: ]
426 # OBJECT:File: [[FILE2]]
427 # ARCHIVE:File: [[FILE]]({{.*02}})
429 # MULTIPLE-GNU-EMPTY:
430 # MULTIPLE-GNU-NEXT:Stack Sizes:
431 # MULTIPLE-GNU-NEXT: Size Function
432 # MULTIPLE-GNU-NEXT: 16 foo
433 # MULTIPLE-GNU-NEXT: 32 bar
435 # MULTIPLE-LLVM: StackSizes [
436 # MULTIPLE-LLVM-NEXT: Entry {
437 # MULTIPLE-LLVM-NEXT: Function: foo
438 # MULTIPLE-LLVM-NEXT: Size: 0x10
439 # MULTIPLE-LLVM-NEXT: }
440 # MULTIPLE-LLVM-NEXT: Entry {
441 # MULTIPLE-LLVM-NEXT: Function: bar
442 # MULTIPLE-LLVM-NEXT: Size: 0x20
443 # MULTIPLE-LLVM-NEXT: }
444 # MULTIPLE-LLVM-NEXT: ]
446 ## Check that we do not consider symbols that are not function symbols, even though
447 ## a relocation references them.
449 # RUN: yaml2obj --docnum=9 %s > %t14
450 # RUN: llvm-readelf --stack-sizes %t14 2> %t14-gnu.err | FileCheck %s --check-prefix=NONFUNCTIONSYM-GNU
451 # RUN: FileCheck %s < %t14-gnu.err --check-prefix=NONFUNCTIONSYM-ERR -DFILE=%t14
452 # RUN: llvm-readobj --stack-sizes %t14 2> %t14-llvm.err | FileCheck %s --check-prefix=NONFUNCTIONSYM-LLVM
453 # RUN: FileCheck %s < %t14-llvm.err --check-prefix=NONFUNCTIONSYM-ERR -DFILE=%t14
455 # NONFUNCTIONSYM-GNU: Stack Sizes:
456 # NONFUNCTIONSYM-GNU: 0 ?
458 # NONFUNCTIONSYM-LLVM: StackSizes [
459 # NONFUNCTIONSYM-LLVM-NEXT: Entry {
460 # NONFUNCTIONSYM-LLVM-NEXT: Function: ?
461 # NONFUNCTIONSYM-LLVM-NEXT: Size: 0x0
462 # NONFUNCTIONSYM-LLVM-NEXT: }
463 # NONFUNCTIONSYM-LLVM-NEXT: ]
465 # NONFUNCTIONSYM-ERR: warning: '[[FILE]]': could not identify function symbol for stack size entry
482 - Name: .rela.stack_sizes
495 ## Check that we report an error when we find an unsupported relocation
496 ## in the section that contains the stack size entries' relocations.
498 # RUN: yaml2obj --docnum=10 %s > %t15
499 # RUN: not llvm-readelf --stack-sizes %t15 2>&1 | FileCheck %s --check-prefix=UNSUPPRELOC -DFILE=%t15
500 # RUN: not llvm-readobj --stack-sizes %t15 2>&1 | FileCheck %s --check-prefix=UNSUPPRELOC -DFILE=%t15
502 # UNSUPPRELOC: error: '[[FILE]]': unsupported relocation type in section .rela.stack_sizes: R_X86_64_RELATIVE
518 - Name: .rela.stack_sizes
524 Type: R_X86_64_RELATIVE
531 ## Check that warning messages in archives do not impact other members. In the following
532 ## test, the first archive member generates a warning and we make sure all the information
535 # RUN: llvm-ar rc %t2.a %t04 %t01
536 # RUN: llvm-readelf --stack-sizes %t2.a 2>&1 | FileCheck %s --check-prefix=ARCHIVEWARN-GNU \
537 # RUN: -DFILE=%t2.a --strict-whitespace --match-full-lines
538 # RUN: llvm-readobj --stack-sizes %t2.a 2>&1 | FileCheck %s --check-prefix=ARCHIVEWARN-LLVM -DFILE=%t2.a
540 # ARCHIVEWARN-GNU:File: [[FILE]]({{.*04}})
541 # ARCHIVEWARN-GNU:Stack Sizes:
542 # ARCHIVEWARN-GNU-NEXT: Size Function
543 # ARCHIVEWARN-GNU:{{.*}}: warning: '{{.*04}}': relocation symbol foo is not in the expected section
544 # ARCHIVEWARN-GNU: 8 foo
545 # ARCHIVEWARN-GNU:File: [[FILE]]({{.*01}})
546 # ARCHIVEWARN-GNU:Stack Sizes:
547 # ARCHIVEWARN-GNU-NEXT: Size Function
548 # ARCHIVEWARN-GNU-NEXT: 16 referenced_by_symbol_foo
549 # ARCHIVEWARN-GNU-NEXT: 32 referenced_via_section_bar
550 # ARCHIVEWARN-GNU-NEXT: 8 separate_text_section_baz
551 # ARCHIVEWARN-GNU-NOT:{{.}}
554 # ARCHIVEWARN-LLVM: File: [[FILE]]({{.*04}})
555 # ARCHIVEWARN-LLVM: StackSizes [
556 # ARCHIVEWARN-LLVM: warning: '{{.*04}}': relocation symbol foo is not in the expected section
557 # ARCHIVEWARN-LLVM-NEXT: Entry {
558 # ARCHIVEWARN-LLVM-NEXT: Function: foo
559 # ARCHIVEWARN-LLVM-NEXT: Size: 0x8
560 # ARCHIVEWARN-LLVM-NEXT: }
561 # ARCHIVEWARN-LLVM-NEXT: ]
562 # ARCHIVEWARN-LLVM: File: [[FILE]]({{.*01}})
563 # ARCHIVEWARN-LLVM: StackSizes [
564 # ARCHIVEWARN-LLVM-NEXT: Entry {
565 # ARCHIVEWARN-LLVM-NEXT: Function: referenced_by_symbol_foo
566 # ARCHIVEWARN-LLVM-NEXT: Size: 0x10
567 # ARCHIVEWARN-LLVM-NEXT: }
568 # ARCHIVEWARN-LLVM-NEXT: Entry {
569 # ARCHIVEWARN-LLVM-NEXT: Function: referenced_via_section_bar
570 # ARCHIVEWARN-LLVM-NEXT: Size: 0x20
571 # ARCHIVEWARN-LLVM-NEXT: }
572 # ARCHIVEWARN-LLVM-NEXT: Entry {
573 # ARCHIVEWARN-LLVM-NEXT: Function: separate_text_section_baz
574 # ARCHIVEWARN-LLVM-NEXT: Size: 0x8
575 # ARCHIVEWARN-LLVM-NEXT: }
576 # ARCHIVEWARN-LLVM-NEXT: ]
578 ## Check that we demangle function names when requested.
580 # RUN: yaml2obj --docnum=11 %s > %t16
581 # RUN: llvm-readelf --stack-sizes --demangle %t16 | FileCheck %s --check-prefix=DEMANGLE-GNU
582 # RUN: llvm-readobj --stack-sizes --demangle %t16 | FileCheck %s --check-prefix=DEMANGLE-LLVM
584 # DEMANGLE-GNU: 16 foo(float)
585 # DEMANGLE-LLVM: Function: foo(float)
611 ## Check that we report an error when we are unable to resolve a relocation for a given ELF architecture.
612 ## Here we have a 64-bit relocation used in a 32-bit object.
614 # RUN: yaml2obj --docnum=12 %s > %t17
615 # RUN: not llvm-readelf --stack-sizes %t17 2>&1 | FileCheck %s -DFILE=%t17 --check-prefix=UNSUPPRELOC2
616 # RUN: not llvm-readobj --stack-sizes %t17 2>&1 | FileCheck %s -DFILE=%t17 --check-prefix=UNSUPPRELOC2
618 # UNSUPPRELOC2: error: '[[FILE]]': unsupported relocation type in section .rela.stack_sizes: R_X86_64_64
630 - Name: .rela.stack_sizes