xref: /llvm-project/llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test (revision a7a447be0fa934505f0c423fb97b91a68c1cc715)
1## Show the disassembly behaviour when dynamic symbols are present.
2# RUN: yaml2obj %s -o %t
3
4## Case 1: Both static and dynamic symbols are present. Only static
5## symbols are displayed.
6# RUN: llvm-objdump -d %t | FileCheck %s --check-prefixes=CHECK,STATIC
7
8## Case 2: Only the dynamic symbols are present. These should be displayed, if
9## they meet the necessary criteria.
10# RUN: llvm-objcopy --strip-all %t %t2
11# RUN: llvm-objdump -d %t2 | FileCheck %s --check-prefixes=CHECK,DYN
12
13# CHECK:       Disassembly of section .text:
14# CHECK-EMPTY:
15# STATIC-NEXT: 0000000000001000 <.text>:
16# DYN-NEXT:    0000000000001000 <only_dyn>:
17# CHECK-NEXT:      1000:
18# CHECK-EMPTY:
19# STATIC-NEXT: 0000000000001001 <both_static>:
20# DYN-NEXT:    0000000000001001 <both_dyn>:
21# CHECK-NEXT:      1001:
22# STATIC-EMPTY:
23# STATIC-NEXT: 0000000000001002 <only_static>:
24# CHECK-NEXT:      1002:
25# DYN-EMPTY:
26# DYN-NEXT:    0000000000001003 <object>:
27# CHECK-NEXT:      1003:
28# DYN-EMPTY:
29# DYN-NEXT:    0000000000001004 <zero_sized>:
30# CHECK-NEXT:      1004:
31# DYN-EMPTY:
32# DYN-NEXT:    0000000000001005 <common>:
33# CHECK-NEXT:      1005:
34# DYN-EMPTY:
35# DYN-NEXT:    0000000000001006 <loos>:
36# CHECK-NEXT:      1006:
37# DYN-EMPTY:
38# DYN-NEXT:    0000000000001007 <loproc>:
39# CHECK-NEXT:      1007:
40# CHECK-NEXT:      1008:
41# CHECK-NEXT:      1009:
42# CHECK-NEXT:      100a:
43# CHECK-NEXT:      100b:{{.*}}
44# CHECK-NOT:   {{.}}
45
46--- !ELF
47FileHeader:
48  Class:   ELFCLASS64
49  Data:    ELFDATA2LSB
50  Type:    ET_DYN
51  Machine: EM_X86_64
52Sections:
53  - Name:    .text
54    Type:    SHT_PROGBITS
55    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
56    Address: 0x1000
57    Content: 909090909090909090909090
58ProgramHeaders:
59  - Type:     PT_LOAD
60    VAddr:    0x1000
61    FirstSec: .text
62    LastSec:  .text
63Symbols:
64  - Name:    both_static
65    Value:   0x1001
66    Section: .text
67    Binding: STB_GLOBAL
68  - Name:    only_static
69    Value:   0x1002
70    Section: .text
71    Binding: STB_GLOBAL
72DynamicSymbols:
73  - Name:    only_dyn
74    Value:   0x1000
75    Section: .text
76    Size:    1
77    Type:    STT_FUNC
78    Binding: STB_GLOBAL
79  - Name:    both_dyn
80    Value:   0x1001
81    Section: .text
82    Size:    1
83    Type:    STT_NOTYPE
84    Binding: STB_GLOBAL
85  - Name:    object
86    Value:   0x1003
87    Section: .text
88    Size:    1
89    Type:    STT_OBJECT
90    Binding: STB_GLOBAL
91  - Name:    zero_sized
92    Value:   0x1004
93    Section: .text
94    Type:    STT_FUNC
95    Binding: STB_GLOBAL
96  - Name:    common
97    Value:   0x1005
98    Section: .text
99    Size:    1
100    Type:    STT_COMMON
101    Binding: STB_GLOBAL
102  - Name:    loos
103    Value:   0x1006
104    Section: .text
105    Size:    1
106    Type:    10
107    Binding: STB_GLOBAL
108  - Name:    loproc
109    Value:   0x1007
110    Section: .text
111    Size:    1
112    Type:    13
113    Binding: STB_GLOBAL
114  ## The rest of the dynamic symbols won't be used for various reasons.
115  - Name:    section
116    Value:   0x1008
117    Section: .text
118    Size:    1
119    Type:    STT_SECTION
120    Binding: STB_GLOBAL
121  - Name:    '' # No name
122    Value:   0x1009
123    Section: .text
124    Size:    1
125    Type:    STT_FUNC
126    Binding: STB_GLOBAL
127  - Name:    absolute
128    Value:   0x100a
129    Index:   SHN_ABS
130    Size:    1
131    Type:    STT_FUNC
132    Binding: STB_GLOBAL
133  - Name:    undefined
134    Value:   0x100b
135    Index:   SHN_UNDEF
136    Size:    1
137    Type:    STT_FUNC
138    Binding: STB_GLOBAL
139