xref: /llvm-project/llvm/test/DebugInfo/Symbolize/ELF/symtab-file2.yaml (revision f5ded4eaa4faafddbe60e7fc3867ce86fb197dbe)
1# RUN: yaml2obj --docnum=1 %s -o %t1
2# RUN: llvm-symbolizer --obj=%t1 0 1 2 | FileCheck %s
3
4## The local symbol has no preceding STT_FILE. Its filename is unavailable.
5# CHECK:       local
6# CHECK-NEXT:  ??:0:0
7# CHECK-EMPTY:
8
9## All local symbols precede all non-local symbols. When there are multiple
10## STT_FILE symbols, we cannot tell which file defines the non-local symbol in
11## question. We could tell if there is only one STT_FILE but in reality there
12## are always more than one file, so implementing the special case is not useful.
13# CHECK-NEXT:  global
14# CHECK-NEXT:  ??:0:0
15# CHECK-EMPTY:
16# CHECK-NEXT:  weak
17# CHECK-NEXT:  ??:0:0
18# CHECK-EMPTY:
19
20--- !ELF
21FileHeader:
22  Class:   ELFCLASS64
23  Data:    ELFDATA2LSB
24  Type:    ET_DYN
25  Machine: EM_X86_64
26Sections:
27  - Name:  .text
28    Type:  SHT_PROGBITS
29    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
30    Size:  3
31Symbols:
32  - Name:    local
33    Section: .text
34    Value:   0
35  - Name:    1.c
36    Type:    STT_FILE
37    Index:   SHN_ABS
38  - Name:    global
39    Binding: STB_GLOBAL
40    Section: .text
41    Value:   1
42  - Name:    weak
43    Binding: STB_WEAK
44    Section: .text
45    Value:   2
46
47## If st_name of the STT_FILE symbols is invalid, the symbol name is lost as well.
48## TODO Keep the symbol name.
49# RUN: yaml2obj --docnum=2 %s -o %t2
50# RUN: not llvm-symbolizer --obj=%t2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK2
51
52# CHECK2:      llvm-symbolizer{{.*}}: error: '{{.*}}symtab-file2.yaml.tmp2': st_name (0xffff) is past the end of the string table of size
53
54--- !ELF
55FileHeader:
56  Class:   ELFCLASS64
57  Data:    ELFDATA2LSB
58  Type:    ET_DYN
59  Machine: EM_X86_64
60Sections:
61  - Name:  .text
62    Type:  SHT_PROGBITS
63    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
64    Size:  1
65Symbols:
66  - StName:  0xffff
67    Type:    STT_FILE
68    Index:   SHN_ABS
69  - Name:    local
70    Section: .text
71
72# RUN: yaml2obj --docnum=3 %s -o %t3
73# RUN: llvm-symbolizer --obj=%t3 'DATA 0x1001' 2>&1 | FileCheck %s --check-prefix=CHECK3
74
75# CHECK3:      code
76# CHECK3-NEXT: 4096 2
77# CHECK3-NEXT: ??:?
78# CHECK3-EMPTY:
79
80--- !ELF
81FileHeader:
82  Class:   ELFCLASS64
83  Data:    ELFDATA2LSB
84  Type:    ET_DYN
85  Machine: EM_X86_64
86Sections:
87  - Name:    .text
88    Type:    SHT_PROGBITS
89    Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
90    Address: 0x1000
91    Size:    1
92  - Name:    .debug
93    Type:    SHT_PROGBITS
94    Address: 0x0000
95    Size:    0xFFFF
96Symbols:
97  - Name:    debug
98    Section: .debug
99    Binding: STB_WEAK
100    Value:   0x1001
101    Size:    0
102  - Name:    code
103    Section: .text
104    Binding: STB_WEAK
105    Value:   0x1000
106    Size:    2
107