• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3// RUN: ld.lld %t -o %t2
4// RUN: llvm-readobj --symbols --sections %t2 | FileCheck %s
5
6.type _start, @function
7.globl _start
8_start:
9
10.type foo, @object
11.weak foo
12foo:
13
14.type bar, @object
15.weak bar
16.long bar
17
18.section        foobar,"a",@nobits,unique,1
19.globl zed
20zed:
21        .long 0
22.globl zed2
23zed2:
24.long 0
25
26.section        foobar,"a",@nobits,unique,2
27.globl zed3
28.size zed3, 4
29zed3:
30
31.globl abs
32abs = 0x123
33
34.comm common,4,4
35
36.global protected
37.protected protected
38protected:
39
40.global hidden
41.hidden hidden
42hidden:
43
44.global internal
45.internal internal
46internal:
47
48// CHECK:      Name: foobar
49// CHECK-NEXT: Type: SHT_NOBITS
50// CHECK-NEXT: Flags [
51// CHECK-NEXT:   SHF_ALLOC
52// CHECK-NEXT: ]
53// CHECK-NEXT: Address: 0x200158
54
55// CHECK:      Name: .text
56// CHECK-NEXT: Type: SHT_PROGBITS
57// CHECK-NEXT: Flags [
58// CHECK-NEXT:   SHF_ALLOC
59// CHECK-NEXT:   SHF_EXECINSTR
60// CHECK-NEXT: ]
61// CHECK-NEXT: Address: 0x201160
62
63// CHECK:      Name: .bss
64// CHECK-NEXT: Type: SHT_NOBITS
65// CHECK-NEXT: Flags [
66// CHECK-NEXT:   SHF_ALLOC
67// CHECK-NEXT:   SHF_WRITE
68// CHECK-NEXT: ]
69// CHECK-NEXT: Address: 0x202164
70// CHECK-NEXT: Offset:
71// CHECK-NEXT: Size: 4
72
73// CHECK:      Symbols [
74// CHECK-NEXT:   Symbol {
75// CHECK-NEXT:     Name:  (0)
76// CHECK-NEXT:     Value: 0x0
77// CHECK-NEXT:     Size: 0
78// CHECK-NEXT:     Binding: Local (0x0)
79// CHECK-NEXT:     Type: None (0x0)
80// CHECK-NEXT:     Other: 0
81// CHECK-NEXT:     Section: Undefined (0x0)
82// CHECK-NEXT:   }
83// CHECK-NEXT: Symbol {
84// CHECK-NEXT:     Name: hidden
85// CHECK-NEXT:     Value: 0x200160
86// CHECK-NEXT:     Size: 0
87// CHECK-NEXT:     Binding: Local
88// CHECK-NEXT:     Type: None
89// CHECK-NEXT:     Other [ (0x2)
90// CHECK-NEXT:       STV_HIDDEN
91// CHECK-NEXT:     ]
92// CHECK-NEXT:     Section: foobar
93// CHECK-NEXT:   }
94// CHECK-NEXT:   Symbol {
95// CHECK-NEXT:     Name: internal
96// CHECK-NEXT:     Value: 0x200160
97// CHECK-NEXT:     Size: 0
98// CHECK-NEXT:     Binding: Local
99// CHECK-NEXT:     Type: None
100// CHECK-NEXT:     Other [ (0x1)
101// CHECK-NEXT:       STV_INTERNAL
102// CHECK-NEXT:     ]
103// CHECK-NEXT:     Section: foobar
104// CHECK-NEXT:   }
105// CHECK-NEXT:   Symbol {
106// CHECK-NEXT:     Name: _start
107// CHECK-NEXT:     Value: 0x201160
108// CHECK-NEXT:     Size: 0
109// CHECK-NEXT:     Binding: Global (0x1)
110// CHECK-NEXT:     Type: Function
111// CHECK-NEXT:     Other: 0
112// CHECK-NEXT:     Section: .text
113// CHECK-NEXT:   }
114// CHECK-NEXT:   Symbol {
115// CHECK-NEXT:     Name: abs
116// CHECK-NEXT:     Value: 0x123
117// CHECK-NEXT:     Size: 0
118// CHECK-NEXT:     Binding: Global
119// CHECK-NEXT:     Type: None
120// CHECK-NEXT:     Other: 0
121// CHECK-NEXT:     Section: Absolute
122// CHECK-NEXT:   }
123// CHECK-NEXT:   Symbol {
124// CHECK-NEXT:     Name: bar
125// CHECK-NEXT:     Value: 0x0
126// CHECK-NEXT:     Size: 0
127// CHECK-NEXT:     Binding: Weak (0x2)
128// CHECK-NEXT:     Type: Object (0x1)
129// CHECK-NEXT:     Other: 0
130// CHECK-NEXT:     Section: Undefined (0x0)
131// CHECK-NEXT:   }
132// CHECK-NEXT:   Symbol {
133// CHECK-NEXT:     Name: common
134// CHECK-NEXT:     Value: 0x202164
135// CHECK-NEXT:     Size: 4
136// CHECK-NEXT:     Binding: Global
137// CHECK-NEXT:     Type: Object
138// CHECK-NEXT:     Other: 0
139// CHECK-NEXT:     Section: .bss
140// CHECK-NEXT:   }
141// CHECK-NEXT:   Symbol {
142// CHECK-NEXT:     Name: foo
143// CHECK-NEXT:     Value: 0x201160
144// CHECK-NEXT:     Size: 0
145// CHECK-NEXT:     Binding: Weak (0x2)
146// CHECK-NEXT:     Type: Object
147// CHECK-NEXT:     Other: 0
148// CHECK-NEXT:     Section: .text
149// CHECK-NEXT:   }
150// CHECK-NEXT:   Symbol {
151// CHECK-NEXT:     Name: protected
152// CHECK-NEXT:     Value: 0x200160
153// CHECK-NEXT:     Size: 0
154// CHECK-NEXT:     Binding: Global
155// CHECK-NEXT:     Type: None
156// CHECK-NEXT:     Other [ (0x3)
157// CHECK-NEXT:       STV_PROTECTED
158// CHECK-NEXT:     ]
159// CHECK-NEXT:     Section: foobar
160// CHECK-NEXT:   }
161// CHECK-NEXT:   Symbol {
162// CHECK-NEXT:     Name: zed
163// CHECK-NEXT:     Value: 0x200158
164// CHECK-NEXT:     Size: 0
165// CHECK-NEXT:     Binding: Global (0x1)
166// CHECK-NEXT:     Type: None
167// CHECK-NEXT:     Other: 0
168// CHECK-NEXT:     Section: foobar
169// CHECK-NEXT:   }
170// CHECK-NEXT:   Symbol {
171// CHECK-NEXT:     Name: zed2
172// CHECK-NEXT:     Value: 0x20015C
173// CHECK-NEXT:     Size: 0
174// CHECK-NEXT:     Binding: Global
175// CHECK-NEXT:     Type: None
176// CHECK-NEXT:     Other: 0
177// CHECK-NEXT:     Section: foobar
178// CHECK-NEXT:   }
179// CHECK-NEXT:   Symbol {
180// CHECK-NEXT:     Name: zed3
181// CHECK-NEXT:     Value: 0x200160
182// CHECK-NEXT:     Size: 4
183// CHECK-NEXT:     Binding: Global
184// CHECK-NEXT:     Type: None
185// CHECK-NEXT:     Other: 0
186// CHECK-NEXT:     Section: foobar
187// CHECK-NEXT:   }
188// CHECK-NEXT: ]
189