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
9 # RUN: llvm-readobj --syms --sort-symbols=type,name --macho-dysymtab %t/test | FileCheck %s
11 # CHECK-NEXT: Symbol {
12 # CHECK-NEXT: Name: _dynamic
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)
20 # CHECK-NEXT: Value: 0x0
22 # CHECK-NEXT: Symbol {
23 # CHECK-NEXT: Name: dyld_stub_binder
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)
31 # CHECK-NEXT: Value: 0x0
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)
40 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
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)
49 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
51 # CHECK-NEXT: Symbol {
52 # CHECK-NEXT: Name: __mh_execute_header
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)
60 # CHECK-NEXT: Value: 0x100000000
62 # CHECK-NEXT: Symbol {
63 # CHECK-NEXT: Name: _external
65 # CHECK-NEXT: Type: Section (0xE)
66 # CHECK-NEXT: Section: __data
67 # CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
68 # CHECK-NEXT: Flags [ (0x0)
70 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
72 # CHECK-NEXT: Symbol {
73 # CHECK-NEXT: Name: _external_weak
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)
81 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
83 # CHECK-NEXT: Symbol {
84 # CHECK-NEXT: Name: _main
86 # CHECK-NEXT: Type: Section (0xE)
87 # CHECK-NEXT: Section: __text (0x1)
88 # CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
89 # CHECK-NEXT: Flags [ (0x0)
91 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
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)
101 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
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)
111 # CHECK-NEXT: Value: 0x1{{[0-9a-f]*}}
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
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
127 # YAML-NOT: _unreferenced
134 .globl _main, _external, _private_external, _external_weak, _private_external_weak, _unreferenced
143 .weak_definition _external_weak
147 .private_extern _private_external
151 .weak_definition _private_external_weak
152 .private_extern _private_external_weak
153 _private_external_weak
:
157 callq _private_external
163 ## These are both already in test.s and should make it into the symbol table
165 .globl _external_weak, _private_external_weak
167 .weak_definition _external_weak
170 .weak_definition _private_external_weak
171 .private_extern _private_external_weak
172 _private_external_weak
: