xref: /llvm-project/llvm/test/tools/llvm-objdump/ELF/symbol-table.test (revision 0c2e2f88fbd3f3ffa2e441e08cdd17141e7bea97)
1## Test how --syms/-t prints the static symbol table.
2# RUN: yaml2obj --docnum=1 %s -o %t
3# RUN: llvm-objdump --syms %t > %t.txt
4# RUN: llvm-objdump -t %t | cmp - %t.txt
5# RUN: FileCheck %s --input-file=%t.txt --match-full-lines --strict-whitespace
6
7#      CHECK:{{.*}}file format elf64-x86-64
8#CHECK-EMPTY:
9# CHECK-NEXT:SYMBOL TABLE:
10# CHECK-NEXT:0000000000000000 l    df *ABS*	0000000000000000 a.c
11# CHECK-NEXT:0000000000000000 l    d  .text	0000000000000000 .text
12# CHECK-NEXT:0000000000002000 l     O .data	0000000000000000 local_object
13# CHECK-NEXT:0000000000001fff l     F .text	0000000000000000 local_func
14# CHECK-NEXT:0000000000000000 l       *ABS*	0000000000000000 local_abs
15# CHECK-NEXT:0000000000000000 g       .data	0000000000000000 notype
16# CHECK-NEXT:0000000000000000 g     O .data	0000000000000010 object
17# CHECK-NEXT:0000000000000000 g     F .text	000000000000000f func
18# CHECK-NEXT:0000000000000000 g     O *COM*	0000000000000000 common
19# CHECK-NEXT:0000000000000000 g       .data	0000000000000000 tls
20# CHECK-NEXT:0000000000000000 g   i   .text	0000000000000000 ifunc
21# CHECK-NEXT:0000000000000000 g       .text	0000000000000000 invalid_type
22# CHECK-NEXT:0000000000000000 g       .text	0000000000000000 STT_HIOS
23# CHECK-NEXT:0000000000000000 g       .text	0000000000000000 STT_LOPROC
24# CHECK-NEXT:0000000000000000         *UND*	0000000000000000 undef
25# CHECK-NEXT:0000000000000000         *UND*	0000000000000000 SHN_LOPROC
26# CHECK-NEXT:0000000000000000         *UND*	0000000000000000 SHN_LOOS
27# CHECK-NEXT:0000000000000000         *UND*	0000000000000000 reserve
28# CHECK-NEXT:0000000000000000 g       *ABS*	0000000000000000 abs
29# CHECK-NEXT:0000000000000000         *COM*	0000000000000000 common2
30# CHECK-NEXT:0000000000000000 u     O .data	0000000000000000 gnu_unique
31# CHECK-NEXT:0000000000000000 g       .data	0000000000000000 invalid_binding
32# CHECK-NEXT:0000000000000000 g       .data	0000000000000000 STB_HIOS
33# CHECK-NEXT:0000000000000000 g       .data	0000000000000000 STB_LOPROC
34
35--- !ELF
36FileHeader:
37  Class:   ELFCLASS64
38  Data:    ELFDATA2LSB
39  Type:    ET_EXEC
40  Machine: EM_X86_64
41Sections:
42  - Name:  .text
43    Type:  SHT_PROGBITS
44  - Name:  .data
45    Type:  SHT_PROGBITS
46Symbols:
47  - Name:    "a.c"
48    Type:    STT_FILE
49    Index:   SHN_ABS
50  - Type:    STT_SECTION
51    Section: .text
52  - Name:    local_object
53    Type:    STT_OBJECT
54    Section: .data
55    Value:   0x2000
56  - Name:    local_func
57    Type:    STT_FUNC
58    Section: .text
59    Value:   0x1fff
60  - Name:    local_abs
61    Index:   SHN_ABS
62  - Name:    notype
63    Binding: STB_GLOBAL
64    Section: .data
65  - Name:    object
66    Type:    STT_OBJECT
67    Size:    0x10
68    Binding: STB_GLOBAL
69    Section: .data
70  - Name:    func
71    Type:    STT_FUNC
72    Size:    0xf
73    Binding: STB_GLOBAL
74    Section: .text
75  - Name:    common
76    Type:    STT_COMMON
77    Binding: STB_GLOBAL
78    Section: .data
79  - Name:    tls
80    Type:    STT_TLS
81    Binding: STB_GLOBAL
82    Section: .data
83  - Name:    ifunc
84    Type:    STT_GNU_IFUNC
85    Binding: STB_GLOBAL
86    Section: .text
87  - Name:    invalid_type
88    Type:    7
89    Binding: STB_GLOBAL
90    Section: .text
91  - Name:    STT_HIOS
92    Type:    12
93    Binding: STB_GLOBAL
94    Section: .text
95  - Name:    STT_LOPROC
96    Type:    13
97    Binding: STB_GLOBAL
98    Section: .text
99  - Name:    undef
100    Binding: STB_GLOBAL
101  - Name:    SHN_LOPROC
102    Binding: STB_GLOBAL
103    Index:   0xff00
104  - Name:    SHN_LOOS
105    Binding: STB_GLOBAL
106    Index:   0xff20
107  - Name:    reserve
108    Binding: STB_GLOBAL
109    Index:   0xff40
110  - Name:    abs
111    Index:   SHN_ABS
112    Binding: STB_GLOBAL
113  - Name:    common2
114    Binding: STB_GLOBAL
115    Index:   SHN_COMMON
116  - Name:    gnu_unique
117    Type:    STT_OBJECT
118    Binding: STB_GNU_UNIQUE
119    Section: .data
120  - Name:    invalid_binding
121    Binding: 3
122    Section: .data
123  - Name:    STB_HIOS
124    Binding: 12
125    Section: .data
126  - Name:    STB_LOPROC
127    Binding: 13
128    Section: .data
129
130## For an ELF32 object, print the address and size fields as 32-bit hexadecimals.
131# RUN: yaml2obj --docnum=2 -D BITS=32 %s -o %t.32
132# RUN: llvm-objdump --syms %t.32 | FileCheck --check-prefix=ELF32 %s --match-full-lines --strict-whitespace
133## For an ELF64 object, print the address and size fields as 64-bit hexadecimals.
134# RUN: yaml2obj --docnum=2 -D BITS=64 %s -o %t.64
135# RUN: llvm-objdump --syms %t.64 | FileCheck --check-prefix=ELF64 %s --match-full-lines --strict-whitespace
136
137#      ELF32:SYMBOL TABLE:
138# ELF32-NEXT:00000000         *UND*	00000000 sym
139
140#      ELF64:SYMBOL TABLE:
141# ELF64-NEXT:0000000000000000         *UND*	0000000000000000 sym
142
143--- !ELF
144FileHeader:
145  Class:   ELFCLASS[[BITS]]
146  Data:    ELFDATA2LSB
147  Type:    ET_EXEC
148  Machine: EM_X86_64
149Symbols:
150  - Name: sym
151