1## Check that we correctly display the contents of the .stack_sizes section 2## in a relocatable object file. 3 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 8 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 13# RELOC-GNU-NOT:{{.}} 14 15# RELOC-LLVM: StackSizes [ 16# RELOC-LLVM-NEXT: Entry { 17# RELOC-LLVM-NEXT: Function: referenced_by_symbol_foo 18# RELOC-LLVM-NEXT: Size: 0x10 19# RELOC-LLVM-NEXT: } 20# RELOC-LLVM-NEXT: Entry { 21# RELOC-LLVM-NEXT: Function: referenced_via_section_bar 22# RELOC-LLVM-NEXT: Size: 0x20 23# RELOC-LLVM-NEXT: } 24# RELOC-LLVM-NEXT: Entry { 25# RELOC-LLVM-NEXT: Function: separate_text_section_baz 26# RELOC-LLVM-NEXT: Size: 0x8 27# RELOC-LLVM-NEXT: } 28# RELOC-LLVM-NEXT: ] 29 30--- !ELF 31FileHeader: 32 Class: ELFCLASS64 33 Data: ELFDATA2LSB 34 Type: ET_REL 35 Machine: EM_X86_64 36Sections: 37 - Name: .text 38 Type: SHT_PROGBITS 39 Flags: [SHF_ALLOC] 40 Size: 16 41 - Name: .text.baz 42 Type: SHT_PROGBITS 43 Flags: [SHF_ALLOC] 44 Size: 16 45 - Name: .stack_sizes 46 Type: SHT_PROGBITS 47 Entries: 48 - Size: 0x10 49 - Size: 0x20 50 Link: .text 51 - Name: '.stack_sizes (1)' 52 Type: SHT_PROGBITS 53 Entries: 54 - Address: 0x20 55 Size: 0x8 56 Link: .text.baz 57 - Name: .rela.stack_sizes 58 Type: SHT_RELA 59 Info: .stack_sizes 60 Relocations: 61## A symbol relative reference. 62 - Offset: 0 63 Symbol: referenced_by_symbol_foo 64 Type: R_X86_64_64 65## A section relative reference. 66 - Offset: 9 67 Addend: 16 68 Symbol: .text 69 Type: R_X86_64_64 70 - Name: '.rela.stack_sizes (1)' 71 Type: SHT_RELA 72 Info: '.stack_sizes (1)' 73 Relocations: 74 - Offset: 0 75 Symbol: separate_text_section_baz 76 Type: R_X86_64_64 77Symbols: 78 - Name: separate_text_section_baz 79 Section: .text.baz 80 Type: STT_FUNC 81 - Name: .text 82 Section: .text 83 Type: STT_SECTION 84 - Name: referenced_by_symbol_foo 85 Section: .text 86 Type: STT_FUNC 87 Binding: STB_GLOBAL 88 - Name: referenced_via_section_bar 89 Section: .text 90 Value: 0x10 91 Type: STT_FUNC 92 Binding: STB_GLOBAL 93 94## Check that we correctly report the stack sizes in an executable (non-relocatable) 95## object file. This also shows that the sh_link field is ignored in this situation 96## without warning. 97 98# RUN: yaml2obj --docnum=2 %s -o %t02 99# RUN: llvm-readelf --stack-sizes %t02 2>&1 \ 100# RUN: | FileCheck %s --check-prefix=EXEC-GNU --strict-whitespace \ 101# RUN: --match-full-lines --implicit-check-not=warning: 102# RUN: llvm-readobj --stack-sizes %t02 2>&1 \ 103# RUN: | FileCheck %s --check-prefix=EXEC-LLVM --implicit-check-not=warning: 104 105# EXEC-GNU: Size Function 106# EXEC-GNU-NEXT: 16 other 107# EXEC-GNU-NEXT: 32 other_end 108# EXEC-GNU-NEXT: 48 bar 109# EXEC-GNU-NOT:{{.}} 110 111# EXEC-LLVM: StackSizes [ 112# EXEC-LLVM-NEXT: Entry { 113# EXEC-LLVM-NEXT: Function: other 114# EXEC-LLVM-NEXT: Size: 0x10 115# EXEC-LLVM-NEXT: } 116# EXEC-LLVM-NEXT: Entry { 117# EXEC-LLVM-NEXT: Function: other_end 118# EXEC-LLVM-NEXT: Size: 0x20 119# EXEC-LLVM-NEXT: } 120# EXEC-LLVM-NEXT: Entry { 121# EXEC-LLVM-NEXT: Function: bar 122# EXEC-LLVM-NEXT: Size: 0x30 123# EXEC-LLVM-NEXT: } 124# EXEC-LLVM-NEXT: ] 125 126--- !ELF 127FileHeader: 128 Class: ELFCLASS64 129 Data: ELFDATA2LSB 130 Type: ET_EXEC 131 Machine: EM_X86_64 132Sections: 133 - Name: .text 134 Type: SHT_PROGBITS 135 Flags: [SHF_ALLOC] 136 Size: 16 137 - Name: .text2 138 Type: SHT_PROGBITS 139 Flags: [SHF_ALLOC] 140 Size: 16 141 - Name: .stack_sizes 142 Type: SHT_PROGBITS 143 Entries: 144 - Address: 0x0 145 Size: 0x10 146 - Address: 0x10 147 Size: 0x20 148 - Address: 0x20 149 Size: 0x30 150 Link: .text2 151Symbols: 152 ## Undefined symbols are ignored. 153 - Name: undefined 154 Type: STT_FUNC 155 Binding: STB_GLOBAL 156 ## sh_link of .stack_sizes is ignored for non-reloctable objects. 157 - Name: other 158 Section: .text 159 Value: 0 160 Type: STT_FUNC 161 Binding: STB_GLOBAL 162 ## If two symbols have the same value, the first is picked, regardless of 163 ## the sh_link value of the .stack_sizes section. 164 - Name: other_end 165 Section: .text 166 Value: 0x10 167 Type: STT_FUNC 168 Binding: STB_GLOBAL 169 - Name: foo 170 Section: .text2 171 Value: 0x10 172 Type: STT_FUNC 173 Binding: STB_GLOBAL 174 - Name: bar 175 Section: .text2 176 Value: 0x20 177 Type: STT_FUNC 178 Binding: STB_GLOBAL 179 180## Check that we report an error when we find relocations whose offsets point outside 181## of the .stack_sizes section. 182 183# RUN: yaml2obj --docnum=3 %s -o %t03 184# RUN: not llvm-readelf --stack-sizes %t03 2>&1 | FileCheck %s --check-prefix=SHORT -DFILE=%t03 185# RUN: not llvm-readobj --stack-sizes %t03 2>&1 | FileCheck %s --check-prefix=SHORT -DFILE=%t03 186 187# SHORT: error: '[[FILE]]': found invalid relocation offset into section .stack_sizes while trying to extract a stack size entry 188 189--- !ELF 190FileHeader: 191 Class: ELFCLASS64 192 Data: ELFDATA2LSB 193 Type: ET_REL 194 Machine: EM_X86_64 195Sections: 196 - Name: .text 197 Type: SHT_PROGBITS 198 Flags: [SHF_ALLOC] 199 Size: 16 200 - Name: .stack_sizes 201 Type: SHT_PROGBITS 202 Content: "00" 203 Link: .text 204 - Name: .rela.stack_sizes 205 Type: SHT_RELA 206 Info: .stack_sizes 207 Relocations: 208 - Offset: 1 209 Symbol: foo 210 Type: R_X86_64_64 211Symbols: 212 - Name: foo 213 Section: .text 214 Type: STT_FUNC 215 Binding: STB_GLOBAL 216 217## Check that we warn about a function symbol that is not in the section 218## that is referenced by the stack sizes section's sh_link, for relocatable 219## output. 220 221# RUN: yaml2obj --docnum=4 %s -o %t04 222# RUN: llvm-readelf --stack-sizes %t04 2> %t04-gnu.err | FileCheck %s --check-prefix=WRONGSECTION-GNU 223# RUN: FileCheck %s < %t04-gnu.err --check-prefix=WRONGSECTION-ERR -DFILE=%t04 224# RUN: llvm-readobj --stack-sizes %t04 2> %t04-llvm.err | FileCheck %s --check-prefix=WRONGSECTION-LLVM 225# RUN: FileCheck %s < %t04-llvm.err --check-prefix=WRONGSECTION-ERR -DFILE=%t04 226 227# RUN: llvm-readelf --stack-sizes --demangle %t04 2>&1 | FileCheck %s --check-prefix=WRONGSECTION-DEMANGLE-ERR -DFILE=%t04 228# RUN: llvm-readobj --stack-sizes --demangle %t04 2>&1 | FileCheck %s --check-prefix=WRONGSECTION-DEMANGLE-ERR -DFILE=%t04 229 230# WRONGSECTION-GNU: Size Function 231# WRONGSECTION-GNU-NEXT: 8 _Z3foof 232 233# WRONGSECTION-LLVM: StackSizes [ 234# WRONGSECTION-LLVM-NEXT: Entry { 235# WRONGSECTION-LLVM-NEXT: Function: _Z3foof 236# WRONGSECTION-LLVM-NEXT: Size: 0x8 237# WRONGSECTION-LLVM-NEXT: } 238# WRONGSECTION-LLVM-NEXT: ] 239 240# WRONGSECTION-ERR: warning: '[[FILE]]': relocation symbol '_Z3foof' is not in the expected section 241# WRONGSECTION-DEMANGLE-ERR: warning: '[[FILE]]': relocation symbol 'foo(float)' is not in the expected section 242 243--- !ELF 244FileHeader: 245 Class: ELFCLASS64 246 Data: ELFDATA2LSB 247 Type: ET_REL 248 Machine: EM_X86_64 249Sections: 250 - Name: .text 251 Type: SHT_PROGBITS 252 Size: 8 253 - Name: .text2 254 Type: SHT_PROGBITS 255 Size: 8 256 Flags: [SHF_ALLOC] 257 - Name: .stack_sizes 258 Type: SHT_PROGBITS 259 Entries: 260 - Size: 0x8 261 Link: .text2 262 - Name: .rela.stack_sizes 263 Type: SHT_RELA 264 Info: .stack_sizes 265 Relocations: 266 - Offset: 0 267 Symbol: _Z3foof 268 Type: R_X86_64_64 269Symbols: 270 - Name: _Z3foof 271 Section: .text 272 Type: STT_FUNC 273 Binding: STB_GLOBAL 274 275## Check that we report an error when a stack sizes section ends with an incomplete stack size entry. 276 277# RUN: yaml2obj --docnum=5 %s -o %t05 278# RUN: not llvm-readelf --stack-sizes %t05 2>&1 | \ 279# RUN: FileCheck %s --check-prefix=SUDDENEND -DFILE=%t05 280# RUN: not llvm-readobj --stack-sizes %t05 2>&1 | \ 281# RUN: FileCheck %s --check-prefix=SUDDENEND -DFILE=%t05 282 283# SUDDENEND: error: '[[FILE]]': section .stack_sizes ended while trying to extract a stack size entry 284 285--- !ELF 286FileHeader: 287 Class: ELFCLASS64 288 Data: ELFDATA2LSB 289 Type: ET_EXEC 290 Machine: EM_X86_64 291Sections: 292 - Name: .text 293 Type: SHT_PROGBITS 294 Flags: [SHF_ALLOC] 295 Size: 16 296 - Name: .stack_sizes 297 Type: SHT_PROGBITS 298 Content: "10000000" 299 Link: .text 300Symbols: 301 - Name: foo 302 Section: .text 303 Value: 0x10 304 Type: STT_FUNC 305 Binding: STB_GLOBAL 306 307## Check that we report an invalid stack size, which is represented by a ULEB that 308## ends in a byte with the high bit set. 309 310# RUN: yaml2obj --docnum=6 %s -o %t06 311# RUN: not llvm-readelf --stack-sizes %t06 2>&1 | FileCheck %s --check-prefix=BADSIZE -DFILE=%t06 312# RUN: not llvm-readobj --stack-sizes %t06 2>&1 | FileCheck %s --check-prefix=BADSIZE -DFILE=%t06 313 314# BADSIZE: error: '[[FILE]]': could not extract a valid stack size in section .stack_sizes 315 316--- !ELF 317FileHeader: 318 Class: ELFCLASS64 319 Data: ELFDATA2LSB 320 Type: ET_EXEC 321 Machine: EM_X86_64 322Sections: 323 - Name: .text 324 Type: SHT_PROGBITS 325 Flags: [SHF_ALLOC] 326 Size: 16 327 - Name: .stack_sizes 328 Type: SHT_PROGBITS 329 Content: "100000000000000080" 330 Link: .text 331Symbols: 332 - Name: foo 333 Section: .text 334 Value: 0x10 335 Type: STT_FUNC 336 Binding: STB_GLOBAL 337 338## Check that we report a warning when a relocation symbol does not belong to a 339## valid section. We expect a stack size entry with an unknown symbol in the 340## output. 341 342# RUN: yaml2obj --docnum=7 %s -o %t07 343# RUN: llvm-readelf --stack-sizes %t07 2> %t07-gnu.err | FileCheck %s --check-prefix=BADSECTION-OUT-GNU 344# RUN: FileCheck %s < %t07-gnu.err --check-prefix=BADSECTION-ERR -DFILE=%t07 345# RUN: llvm-readobj --stack-sizes %t07 2> %t07-llvm.err | FileCheck %s --check-prefix=BADSECTION-OUT-LLVM 346# RUN: FileCheck %s < %t07-llvm.err --check-prefix=BADSECTION-ERR -DFILE=%t07 347 348# RUN: llvm-readelf --stack-sizes --demangle %t07 2>&1 | FileCheck %s --check-prefix=BADSECTION-DEMANGLE-ERR -DFILE=%t07 349# RUN: llvm-readobj --stack-sizes --demangle %t07 2>&1 | FileCheck %s --check-prefix=BADSECTION-DEMANGLE-ERR -DFILE=%t07 350 351# BADSECTION-OUT-GNU: Size Function 352# BADSECTION-OUT-GNU: 8 ? 353 354# BADSECTION-OUT-LLVM: StackSizes [ 355# BADSECTION-OUT-LLVM-NEXT: Entry { 356# BADSECTION-OUT-LLVM-NEXT: Function: ? 357# BADSECTION-OUT-LLVM-NEXT: Size: 0x8 358# BADSECTION-OUT-LLVM-NEXT: } 359# BADSECTION-OUT-LLVM-NEXT: ] 360 361# BADSECTION-ERR: warning: '[[FILE]]': cannot identify the section for relocation symbol '_Z3foof' 362# BADSECTION-DEMANGLE-ERR: warning: '[[FILE]]': cannot identify the section for relocation symbol 'foo(float)' 363 364--- !ELF 365FileHeader: 366 Class: ELFCLASS64 367 Data: ELFDATA2LSB 368 Type: ET_REL 369 Machine: EM_X86_64 370Sections: 371 - Name: .text 372 Type: SHT_PROGBITS 373 Size: 8 374 - Name: .stack_sizes 375 Type: SHT_PROGBITS 376 Link: .text 377 Entries: 378 - Size: 0x8 379 - Name: .rela.stack_sizes 380 Type: SHT_RELA 381 Info: .stack_sizes 382 Relocations: 383 - Offset: 0 384 Symbol: _Z3foof 385 Type: R_X86_64_64 386Symbols: 387 - Name: _Z3foof 388## An invalid section index. 389 Index: 10 390 Type: STT_FUNC 391 Binding: STB_GLOBAL 392 393## Check that we report a warning when a stack sizes section does not come with 394## a corresponding relocation section. 395 396# RUN: yaml2obj --docnum=8 %s -o %t08 397# RUN: llvm-readelf --stack-sizes %t08 2> %t08-gnu.err | FileCheck %s --check-prefix=NORELOCSECTION-OUT-GNU 398# RUN: FileCheck %s < %t08-gnu.err --check-prefix=NORELOCSECTION-ERR -DFILE=%t08 399# RUN: llvm-readobj --stack-sizes %t08 2> %t08-llvm.err | FileCheck %s --check-prefix=NORELOCSECTION-OUT-LLVM 400# RUN: FileCheck %s < %t08-llvm.err --check-prefix=NORELOCSECTION-ERR -DFILE=%t08 401 402# NORELOCSECTION-OUT-GNU: Size Function 403# NORELOCSECTION-OUT-GNU-NOT: {{.}} 404 405# NORELOCSECTION-OUT-LLVM: StackSizes [ 406# NORELOCSECTION-OUT-LLVM-NEXT: ] 407 408# NORELOCSECTION-ERR: warning: '[[FILE]]': section .stack_sizes does not have a corresponding relocation section 409 410--- !ELF 411FileHeader: 412 Class: ELFCLASS64 413 Data: ELFDATA2LSB 414 Type: ET_REL 415 Machine: EM_X86_64 416Sections: 417 - Name: .text 418 Type: SHT_PROGBITS 419 Size: 8 420 - Name: .stack_sizes 421 Type: SHT_PROGBITS 422 Link: .text 423 Entries: 424 - Size: 0x1 425 426## Check that we handle multiple object files, separately and when they 427## are in an archive. This also checks whether we have blank lines between the 428## tables. 429 430# RUN: llvm-ar rc %t1.a %t01 %t02 431# RUN: llvm-readelf --stack-sizes %t01 %t02 \ 432# RUN: | FileCheck %s --check-prefixes=MULTIPLE-GNU,OBJECT -DFILE1=%t01 -DFILE2=%t02 433# RUN: llvm-readelf --stack-sizes %t1.a \ 434# RUN: | FileCheck %s --check-prefixes=MULTIPLE-GNU,ARCHIVE --strict-whitespace\ 435# RUN: --match-full-lines -DFILE=%t1.a 436# RUN: llvm-readobj --stack-sizes %t01 %t02 \ 437# RUN: | FileCheck %s --check-prefixes=MULTIPLE-LLVM,OBJECT -DFILE1=%t01 -DFILE2=%t02 438# RUN: llvm-readobj --stack-sizes %t1.a \ 439# RUN: | FileCheck %s --check-prefixes=MULTIPLE-LLVM,ARCHIVE -DFILE=%t1.a 440 441# OBJECT:File: [[FILE1]] 442# ARCHIVE:File: [[FILE]]({{.*01}}) 443 444# MULTIPLE-GNU:Stack Sizes: 445# MULTIPLE-GNU-NEXT: Size Function 446# MULTIPLE-GNU-NEXT: 16 referenced_by_symbol_foo 447# MULTIPLE-GNU-NEXT: 32 referenced_via_section_bar 448# MULTIPLE-GNU-NEXT: 8 separate_text_section_baz 449# MULTIPLE-GNU-EMPTY: 450 451# MULTIPLE-LLVM: StackSizes [ 452# MULTIPLE-LLVM-NEXT: Entry { 453# MULTIPLE-LLVM-NEXT: Function: referenced_by_symbol_foo 454# MULTIPLE-LLVM-NEXT: Size: 0x10 455# MULTIPLE-LLVM-NEXT: } 456# MULTIPLE-LLVM-NEXT: Entry { 457# MULTIPLE-LLVM-NEXT: Function: referenced_via_section_bar 458# MULTIPLE-LLVM-NEXT: Size: 0x20 459# MULTIPLE-LLVM-NEXT: } 460# MULTIPLE-LLVM-NEXT: Entry { 461# MULTIPLE-LLVM-NEXT: Function: separate_text_section_baz 462# MULTIPLE-LLVM-NEXT: Size: 0x8 463# MULTIPLE-LLVM-NEXT: } 464# MULTIPLE-LLVM-NEXT: ] 465 466# OBJECT:File: [[FILE2]] 467# ARCHIVE:File: [[FILE]]({{.*02}}) 468 469# MULTIPLE-GNU-EMPTY: 470# MULTIPLE-GNU-NEXT:Stack Sizes: 471# MULTIPLE-GNU-NEXT: Size Function 472# MULTIPLE-GNU-NEXT: 16 other 473# MULTIPLE-GNU-NEXT: 32 other_end 474# MULTIPLE-GNU-NEXT: 48 bar 475 476# MULTIPLE-LLVM: StackSizes [ 477# MULTIPLE-LLVM-NEXT: Entry { 478# MULTIPLE-LLVM-NEXT: Function: other 479# MULTIPLE-LLVM-NEXT: Size: 0x10 480# MULTIPLE-LLVM-NEXT: } 481# MULTIPLE-LLVM-NEXT: Entry { 482# MULTIPLE-LLVM-NEXT: Function: other_end 483# MULTIPLE-LLVM-NEXT: Size: 0x20 484# MULTIPLE-LLVM-NEXT: } 485# MULTIPLE-LLVM-NEXT: Entry { 486# MULTIPLE-LLVM-NEXT: Function: bar 487# MULTIPLE-LLVM-NEXT: Size: 0x30 488# MULTIPLE-LLVM-NEXT: } 489# MULTIPLE-LLVM-NEXT: ] 490 491## Check that we do not consider symbols that are not function symbols, even though 492## a relocation references them. 493 494# RUN: yaml2obj --docnum=9 %s -o %t14 495# RUN: llvm-readelf --stack-sizes %t14 2> %t14-gnu.err | FileCheck %s --check-prefix=NONFUNCTIONSYM-GNU 496# RUN: FileCheck %s < %t14-gnu.err --check-prefix=NONFUNCTIONSYM-ERR -DFILE=%t14 497# RUN: llvm-readobj --stack-sizes %t14 2> %t14-llvm.err | FileCheck %s --check-prefix=NONFUNCTIONSYM-LLVM 498# RUN: FileCheck %s < %t14-llvm.err --check-prefix=NONFUNCTIONSYM-ERR -DFILE=%t14 499 500# NONFUNCTIONSYM-GNU: Stack Sizes: 501# NONFUNCTIONSYM-GNU: 0 ? 502 503# NONFUNCTIONSYM-LLVM: StackSizes [ 504# NONFUNCTIONSYM-LLVM-NEXT: Entry { 505# NONFUNCTIONSYM-LLVM-NEXT: Function: ? 506# NONFUNCTIONSYM-LLVM-NEXT: Size: 0x0 507# NONFUNCTIONSYM-LLVM-NEXT: } 508# NONFUNCTIONSYM-LLVM-NEXT: ] 509 510# NONFUNCTIONSYM-ERR: warning: '[[FILE]]': could not identify function symbol for stack size entry 511 512--- !ELF 513FileHeader: 514 Class: ELFCLASS64 515 Data: ELFDATA2LSB 516 Type: ET_REL 517 Machine: EM_X86_64 518Sections: 519 - Name: .text 520 Type: SHT_PROGBITS 521 Size: 16 522 - Name: .stack_sizes 523 Type: SHT_PROGBITS 524 Entries: 525 - Size: 0 526 Link: .text 527 - Name: .rela.stack_sizes 528 Type: SHT_RELA 529 Info: .stack_sizes 530 Relocations: 531 - Offset: 0 532 Symbol: foo 533 Type: R_X86_64_64 534Symbols: 535 - Name: foo 536 Section: .text 537 Type: STT_OBJECT 538 Binding: STB_GLOBAL 539 540## Check that we report an error when we find an unsupported relocation 541## in the section that contains the stack size entries' relocations. 542 543# RUN: yaml2obj --docnum=10 %s -o %t15 544# RUN: not llvm-readelf --stack-sizes %t15 2>&1 | FileCheck %s --check-prefix=UNSUPPRELOC -DFILE=%t15 545# RUN: not llvm-readobj --stack-sizes %t15 2>&1 | FileCheck %s --check-prefix=UNSUPPRELOC -DFILE=%t15 546 547# UNSUPPRELOC: error: '[[FILE]]': unsupported relocation type in section .rela.stack_sizes: R_X86_64_RELATIVE 548 549--- !ELF 550FileHeader: 551 Class: ELFCLASS64 552 Data: ELFDATA2LSB 553 Type: ET_REL 554 Machine: EM_X86_64 555Sections: 556 - Name: .text 557 Type: SHT_PROGBITS 558 Size: 8 559 - Name: .stack_sizes 560 Type: SHT_PROGBITS 561 Link: .text 562 Entries: [] 563 - Name: .rela.stack_sizes 564 Type: SHT_RELA 565 Info: .stack_sizes 566 Relocations: 567 - Offset: 0 568 Symbol: foo 569 Type: R_X86_64_RELATIVE 570Symbols: 571 - Name: foo 572 Section: .text 573 Type: STT_FUNC 574 Binding: STB_GLOBAL 575 576## Check that warning messages in archives do not impact other members. In the following 577## test, the first archive member generates a warning and we make sure all the information 578## is still dumped. 579 580# RUN: llvm-ar rc %t2.a %t04 %t01 581# RUN: llvm-readelf --stack-sizes %t2.a 2>&1 | FileCheck %s --check-prefix=ARCHIVEWARN-GNU \ 582# RUN: -DFILE=%t2.a --strict-whitespace --match-full-lines 583# RUN: llvm-readobj --stack-sizes %t2.a 2>&1 | FileCheck %s --check-prefix=ARCHIVEWARN-LLVM -DFILE=%t2.a 584 585# ARCHIVEWARN-GNU:File: [[FILE]]({{.*04}}) 586# ARCHIVEWARN-GNU:Stack Sizes: 587# ARCHIVEWARN-GNU-NEXT: Size Function 588# ARCHIVEWARN-GNU:{{.*}}: warning: '{{.*04}}': relocation symbol '_Z3foof' is not in the expected section 589# ARCHIVEWARN-GNU: 8 _Z3foof 590# ARCHIVEWARN-GNU:File: [[FILE]]({{.*01}}) 591# ARCHIVEWARN-GNU:Stack Sizes: 592# ARCHIVEWARN-GNU-NEXT: Size Function 593# ARCHIVEWARN-GNU-NEXT: 16 referenced_by_symbol_foo 594# ARCHIVEWARN-GNU-NEXT: 32 referenced_via_section_bar 595# ARCHIVEWARN-GNU-NEXT: 8 separate_text_section_baz 596# ARCHIVEWARN-GNU-NOT:{{.}} 597 598 599# ARCHIVEWARN-LLVM: File: [[FILE]]({{.*04}}) 600# ARCHIVEWARN-LLVM: StackSizes [ 601# ARCHIVEWARN-LLVM: warning: '{{.*04}}': relocation symbol '_Z3foof' is not in the expected section 602# ARCHIVEWARN-LLVM-NEXT: Entry { 603# ARCHIVEWARN-LLVM-NEXT: Function: _Z3foof 604# ARCHIVEWARN-LLVM-NEXT: Size: 0x8 605# ARCHIVEWARN-LLVM-NEXT: } 606# ARCHIVEWARN-LLVM-NEXT: ] 607# ARCHIVEWARN-LLVM: File: [[FILE]]({{.*01}}) 608# ARCHIVEWARN-LLVM: StackSizes [ 609# ARCHIVEWARN-LLVM-NEXT: Entry { 610# ARCHIVEWARN-LLVM-NEXT: Function: referenced_by_symbol_foo 611# ARCHIVEWARN-LLVM-NEXT: Size: 0x10 612# ARCHIVEWARN-LLVM-NEXT: } 613# ARCHIVEWARN-LLVM-NEXT: Entry { 614# ARCHIVEWARN-LLVM-NEXT: Function: referenced_via_section_bar 615# ARCHIVEWARN-LLVM-NEXT: Size: 0x20 616# ARCHIVEWARN-LLVM-NEXT: } 617# ARCHIVEWARN-LLVM-NEXT: Entry { 618# ARCHIVEWARN-LLVM-NEXT: Function: separate_text_section_baz 619# ARCHIVEWARN-LLVM-NEXT: Size: 0x8 620# ARCHIVEWARN-LLVM-NEXT: } 621# ARCHIVEWARN-LLVM-NEXT: ] 622 623## Check that we demangle function names when requested. 624 625# RUN: yaml2obj --docnum=11 %s -o %t16 626# RUN: llvm-readelf --stack-sizes --demangle %t16 | FileCheck %s --check-prefix=DEMANGLE-GNU 627# RUN: llvm-readobj --stack-sizes --demangle %t16 | FileCheck %s --check-prefix=DEMANGLE-LLVM 628 629# DEMANGLE-GNU: 16 foo(float) 630# DEMANGLE-LLVM: Function: foo(float) 631 632--- !ELF 633FileHeader: 634 Class: ELFCLASS64 635 Data: ELFDATA2LSB 636 Type: ET_EXEC 637 Machine: EM_X86_64 638Sections: 639 - Name: .text 640 Type: SHT_PROGBITS 641 Flags: [SHF_ALLOC] 642 Size: 16 643 - Name: .stack_sizes 644 Type: SHT_PROGBITS 645 Entries: 646 - Address: 0x10 647 Size: 0x10 648 Link: .text 649Symbols: 650 - Name: _Z3foof 651 Section: .text 652 Value: 0x10 653 Type: STT_FUNC 654 Binding: STB_GLOBAL 655 656## Check that we report an error when we are unable to resolve a relocation for a given ELF architecture. 657## Here we have a 64-bit relocation used in a 32-bit object. 658 659# RUN: yaml2obj --docnum=12 %s -o %t17 660# RUN: not llvm-readelf --stack-sizes %t17 2>&1 | FileCheck %s -DFILE=%t17 --check-prefix=UNSUPPRELOC2 661# RUN: not llvm-readobj --stack-sizes %t17 2>&1 | FileCheck %s -DFILE=%t17 --check-prefix=UNSUPPRELOC2 662 663# UNSUPPRELOC2: error: '[[FILE]]': unsupported relocation type in section .rela.stack_sizes: R_X86_64_64 664 665--- !ELF 666FileHeader: 667 Class: ELFCLASS32 668 Data: ELFDATA2MSB 669 Type: ET_REL 670 Machine: EM_X86_64 671Sections: 672 - Name: .stack_sizes 673 Type: SHT_PROGBITS 674 Content: "00" 675 - Name: .rela.stack_sizes 676 Type: SHT_RELA 677 Info: .stack_sizes 678 Relocations: 679 - Offset: 0 680 Type: R_X86_64_64 681 682## Check we report an error when dumping stack sizes if the relocated section 683## identified by the sh_info field is invalid. Here the sh_info value is larger than 684## the number of sections. 685 686# RUN: yaml2obj --docnum=13 %s -o %t18 687# RUN: not llvm-readelf --stack-sizes %t18 2>&1 | FileCheck %s -DFILE=%t18 --check-prefix=INVALID-TARGET 688# RUN: not llvm-readobj --stack-sizes %t18 2>&1 | FileCheck %s -DFILE=%t18 --check-prefix=INVALID-TARGET 689 690# INVALID-TARGET: error: '[[FILE]]': .rela.stack_sizes: failed to get a relocated section: invalid section index: 255 691 692--- !ELF 693FileHeader: 694 Class: ELFCLASS32 695 Data: ELFDATA2MSB 696 Type: ET_REL 697 Machine: EM_X86_64 698Sections: 699 - Name: .rela.stack_sizes 700 Type: SHT_RELA 701 Link: 0 702 Info: 0xFF 703 Relocations: [] 704