xref: /llvm-project/llvm/test/DebugInfo/Symbolize/ELF/symtab-file2.yaml (revision f5ded4eaa4faafddbe60e7fc3867ce86fb197dbe)
104a2e126SFangrui Song# RUN: yaml2obj --docnum=1 %s -o %t1
204a2e126SFangrui Song# RUN: llvm-symbolizer --obj=%t1 0 1 2 | FileCheck %s
304a2e126SFangrui Song
404a2e126SFangrui Song## The local symbol has no preceding STT_FILE. Its filename is unavailable.
504a2e126SFangrui Song# CHECK:       local
604a2e126SFangrui Song# CHECK-NEXT:  ??:0:0
704a2e126SFangrui Song# CHECK-EMPTY:
804a2e126SFangrui Song
904a2e126SFangrui Song## All local symbols precede all non-local symbols. When there are multiple
1004a2e126SFangrui Song## STT_FILE symbols, we cannot tell which file defines the non-local symbol in
1104a2e126SFangrui Song## question. We could tell if there is only one STT_FILE but in reality there
1204a2e126SFangrui Song## are always more than one file, so implementing the special case is not useful.
1304a2e126SFangrui Song# CHECK-NEXT:  global
1404a2e126SFangrui Song# CHECK-NEXT:  ??:0:0
1504a2e126SFangrui Song# CHECK-EMPTY:
1604a2e126SFangrui Song# CHECK-NEXT:  weak
1704a2e126SFangrui Song# CHECK-NEXT:  ??:0:0
1804a2e126SFangrui Song# CHECK-EMPTY:
1904a2e126SFangrui Song
2004a2e126SFangrui Song--- !ELF
2104a2e126SFangrui SongFileHeader:
2204a2e126SFangrui Song  Class:   ELFCLASS64
2304a2e126SFangrui Song  Data:    ELFDATA2LSB
2404a2e126SFangrui Song  Type:    ET_DYN
2504a2e126SFangrui Song  Machine: EM_X86_64
2604a2e126SFangrui SongSections:
2704a2e126SFangrui Song  - Name:  .text
2804a2e126SFangrui Song    Type:  SHT_PROGBITS
2904a2e126SFangrui Song    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
3004a2e126SFangrui Song    Size:  3
3104a2e126SFangrui SongSymbols:
3204a2e126SFangrui Song  - Name:    local
3304a2e126SFangrui Song    Section: .text
3404a2e126SFangrui Song    Value:   0
3504a2e126SFangrui Song  - Name:    1.c
3604a2e126SFangrui Song    Type:    STT_FILE
3704a2e126SFangrui Song    Index:   SHN_ABS
3804a2e126SFangrui Song  - Name:    global
3904a2e126SFangrui Song    Binding: STB_GLOBAL
4004a2e126SFangrui Song    Section: .text
4104a2e126SFangrui Song    Value:   1
4204a2e126SFangrui Song  - Name:    weak
4304a2e126SFangrui Song    Binding: STB_WEAK
4404a2e126SFangrui Song    Section: .text
4504a2e126SFangrui Song    Value:   2
4604a2e126SFangrui Song
4704a2e126SFangrui Song## If st_name of the STT_FILE symbols is invalid, the symbol name is lost as well.
4804a2e126SFangrui Song## TODO Keep the symbol name.
4904a2e126SFangrui Song# RUN: yaml2obj --docnum=2 %s -o %t2
50*f5ded4eaSSerge Pavlov# RUN: not llvm-symbolizer --obj=%t2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK2
5104a2e126SFangrui Song
521d5fa4f8SSerge Pavlov# CHECK2:      llvm-symbolizer{{.*}}: error: '{{.*}}symtab-file2.yaml.tmp2': st_name (0xffff) is past the end of the string table of size
5304a2e126SFangrui Song
5404a2e126SFangrui Song--- !ELF
5504a2e126SFangrui SongFileHeader:
5604a2e126SFangrui Song  Class:   ELFCLASS64
5704a2e126SFangrui Song  Data:    ELFDATA2LSB
5804a2e126SFangrui Song  Type:    ET_DYN
5904a2e126SFangrui Song  Machine: EM_X86_64
6004a2e126SFangrui SongSections:
6104a2e126SFangrui Song  - Name:  .text
6204a2e126SFangrui Song    Type:  SHT_PROGBITS
6304a2e126SFangrui Song    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
6404a2e126SFangrui Song    Size:  1
6504a2e126SFangrui SongSymbols:
6604a2e126SFangrui Song  - StName:  0xffff
6704a2e126SFangrui Song    Type:    STT_FILE
6804a2e126SFangrui Song    Index:   SHN_ABS
6904a2e126SFangrui Song  - Name:    local
7004a2e126SFangrui Song    Section: .text
7113f1bc41SGeorge Wright
7213f1bc41SGeorge Wright# RUN: yaml2obj --docnum=3 %s -o %t3
7313f1bc41SGeorge Wright# RUN: llvm-symbolizer --obj=%t3 'DATA 0x1001' 2>&1 | FileCheck %s --check-prefix=CHECK3
7413f1bc41SGeorge Wright
7513f1bc41SGeorge Wright# CHECK3:      code
7613f1bc41SGeorge Wright# CHECK3-NEXT: 4096 2
7713f1bc41SGeorge Wright# CHECK3-NEXT: ??:?
7813f1bc41SGeorge Wright# CHECK3-EMPTY:
7913f1bc41SGeorge Wright
8013f1bc41SGeorge Wright--- !ELF
8113f1bc41SGeorge WrightFileHeader:
8213f1bc41SGeorge Wright  Class:   ELFCLASS64
8313f1bc41SGeorge Wright  Data:    ELFDATA2LSB
8413f1bc41SGeorge Wright  Type:    ET_DYN
8513f1bc41SGeorge Wright  Machine: EM_X86_64
8613f1bc41SGeorge WrightSections:
8713f1bc41SGeorge Wright  - Name:    .text
8813f1bc41SGeorge Wright    Type:    SHT_PROGBITS
8913f1bc41SGeorge Wright    Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
9013f1bc41SGeorge Wright    Address: 0x1000
9113f1bc41SGeorge Wright    Size:    1
9213f1bc41SGeorge Wright  - Name:    .debug
9313f1bc41SGeorge Wright    Type:    SHT_PROGBITS
9413f1bc41SGeorge Wright    Address: 0x0000
9513f1bc41SGeorge Wright    Size:    0xFFFF
9613f1bc41SGeorge WrightSymbols:
9713f1bc41SGeorge Wright  - Name:    debug
9813f1bc41SGeorge Wright    Section: .debug
9913f1bc41SGeorge Wright    Binding: STB_WEAK
10013f1bc41SGeorge Wright    Value:   0x1001
10113f1bc41SGeorge Wright    Size:    0
10213f1bc41SGeorge Wright  - Name:    code
10313f1bc41SGeorge Wright    Section: .text
10413f1bc41SGeorge Wright    Binding: STB_WEAK
10513f1bc41SGeorge Wright    Value:   0x1000
10613f1bc41SGeorge Wright    Size:    2
107