llvm-project
173 строки · 5.1 Кб
1# REQUIRES: x86
2# RUN: rm -rf %t && split-file %s %t
3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test2.s -o %t/test2.o
5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libfoo.s -o %t/libfoo.o
6# RUN: %lld -dylib %t/libfoo.o -o %t/libfoo.dylib
7# RUN: %lld -lSystem %t/test.o %t/test2.o %t/libfoo.dylib -o %t/test
8
9# RUN: llvm-readobj --syms --sort-symbols=type,name --macho-dysymtab %t/test | FileCheck %s
10# CHECK: Symbols [
11# CHECK-NEXT: Symbol {
12# CHECK-NEXT: Name: _dynamic
13# CHECK-NEXT: Extern
14# CHECK-NEXT: Type: Undef (0x0)
15# CHECK-NEXT: Section: (0x0)
16# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
17# CHECK-NEXT: Flags [ (0x200)
18# CHECK-NEXT: AltEntry (0x200)
19# CHECK-NEXT: ]
20# CHECK-NEXT: Value: 0x0
21# CHECK-NEXT: }
22# CHECK-NEXT: Symbol {
23# CHECK-NEXT: Name: dyld_stub_binder
24# CHECK-NEXT: Extern
25# CHECK-NEXT: Type: Undef (0x0)
26# CHECK-NEXT: Section: (0x0)
27# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
28# CHECK-NEXT: Flags [ (0x100)
29# CHECK-NEXT: SymbolResolver (0x100)
30# CHECK-NEXT: ]
31# CHECK-NEXT: Value: 0x0
32# CHECK-NEXT: }
33# CHECK-NEXT: Symbol {
34# CHECK-NEXT: Name: __dyld_private
35# CHECK-NEXT: Type: Section (0xE)
36# CHECK-NEXT: Section: __data
37# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
38# CHECK-NEXT: Flags [ (0x0)
39# CHECK-NEXT: ]
40# CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
41# CHECK-NEXT: }
42# CHECK-NEXT: Symbol {
43# CHECK-NEXT: Name: _local
44# CHECK-NEXT: Type: Section (0xE)
45# CHECK-NEXT: Section: __data
46# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
47# CHECK-NEXT: Flags [ (0x0)
48# CHECK-NEXT: ]
49# CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
50# CHECK-NEXT: }
51# CHECK-NEXT: Symbol {
52# CHECK-NEXT: Name: __mh_execute_header
53# CHECK-NEXT: Extern
54# CHECK-NEXT: Type: Section (0xE)
55# CHECK-NEXT: Section: __text (0x1)
56# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
57# CHECK-NEXT: Flags [ (0x10)
58# CHECK-NEXT: ReferencedDynamically (0x10)
59# CHECK-NEXT: ]
60# CHECK-NEXT: Value: 0x100000000
61# CHECK-NEXT: }
62# CHECK-NEXT: Symbol {
63# CHECK-NEXT: Name: _external
64# CHECK-NEXT: Extern
65# CHECK-NEXT: Type: Section (0xE)
66# CHECK-NEXT: Section: __data
67# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
68# CHECK-NEXT: Flags [ (0x0)
69# CHECK-NEXT: ]
70# CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
71# CHECK-NEXT: }
72# CHECK-NEXT: Symbol {
73# CHECK-NEXT: Name: _external_weak
74# CHECK-NEXT: Extern
75# CHECK-NEXT: Type: Section (0xE)
76# CHECK-NEXT: Section: __text (0x1)
77# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
78# CHECK-NEXT: Flags [ (0x80)
79# CHECK-NEXT: WeakDef (0x80)
80# CHECK-NEXT: ]
81# CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
82# CHECK-NEXT: }
83# CHECK-NEXT: Symbol {
84# CHECK-NEXT: Name: _main
85# CHECK-NEXT: Extern
86# CHECK-NEXT: Type: Section (0xE)
87# CHECK-NEXT: Section: __text (0x1)
88# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
89# CHECK-NEXT: Flags [ (0x0)
90# CHECK-NEXT: ]
91# CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
92# CHECK-NEXT: }
93# CHECK-NEXT: Symbol {
94# CHECK-NEXT: Name: _private_external
95# CHECK-NEXT: PrivateExtern
96# CHECK-NEXT: Type: Section (0xE)
97# CHECK-NEXT: Section: __text (0x1)
98# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
99# CHECK-NEXT: Flags [ (0x0)
100# CHECK-NEXT: ]
101# CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
102# CHECK-NEXT: }
103# CHECK-NEXT: Symbol {
104# CHECK-NEXT: Name: _private_external_weak
105# CHECK-NEXT: PrivateExtern
106# CHECK-NEXT: Type: Section (0xE)
107# CHECK-NEXT: Section: __text (0x1)
108# CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
109# CHECK-NEXT: Flags [ (0x0)
110# CHECK-NEXT: ]
111# CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
112# CHECK-NEXT: }
113# CHECK-NEXT: ]
114# CHECK-NEXT: Dysymtab {
115# CHECK-NEXT: ilocalsym: 0
116# CHECK-NEXT: nlocalsym: 4
117# CHECK-NEXT: iextdefsym: 4
118# CHECK-NEXT: nextdefsym: 4
119# CHECK-NEXT: iundefsym: 8
120# CHECK-NEXT: nundefsym: 2
121
122## Verify that the first entry in the StringTable is a space, and that
123## unreferenced symbols aren't emitted.
124# RUN: obj2yaml %t/test | FileCheck %s --check-prefix=YAML
125# YAML: StringTable:
126# YAML-NEXT: ' '
127# YAML-NOT: _unreferenced
128
129#--- libfoo.s
130.globl _dynamic
131_dynamic:
132
133#--- test.s
134.globl _main, _external, _private_external, _external_weak, _private_external_weak, _unreferenced
135
136.data
137_external:
138.space 1
139_local:
140.space 1
141
142.text
143.weak_definition _external_weak
144_external_weak:
145.space 1
146
147.private_extern _private_external
148_private_external:
149.space 1
150
151.weak_definition _private_external_weak
152.private_extern _private_external_weak
153_private_external_weak:
154.space 1
155
156_main:
157callq _private_external
158callq _dynamic
159mov $0, %rax
160ret
161
162#--- test2.s
163## These are both already in test.s and should make it into the symbol table
164## just once.
165.globl _external_weak, _private_external_weak
166.text
167.weak_definition _external_weak
168_external_weak:
169.space 1
170.weak_definition _private_external_weak
171.private_extern _private_external_weak
172_private_external_weak:
173.space 1
174