1 ; RUN: llc -filetype=obj -wasm-keep-registers %s -o %t.o
2 ; RUN: obj2yaml %t.o | FileCheck %s
3 ; RUN: llvm-objdump -t %t.o | FileCheck --check-prefix=CHECK-SYMS %s
5 target triple = "wasm32-unknown-unknown"
7 ; 'foo_alias()' is weak alias of function 'foo()'
8 ; 'bar_alias' is weak alias of global variable 'bar'
9 ; Generates two exports of the same function, one of them weak
11 @bar = global i32 7, align 8
12 @bar_alias = weak hidden alias i32, i32* @bar
13 @foo_alias = weak hidden alias i32 (), i32 ()* @foo
15 @direct_address = global i32()* @foo, align 8
16 @alias_address = global i32()* @foo_alias, align 8
18 define hidden i32 @foo() #0 {
23 define hidden i32 @call_direct() #0 {
25 %call = call i32 @foo()
29 define hidden i32 @call_alias() #0 {
31 %call = call i32 @foo_alias()
35 define hidden i32 @call_direct_ptr() #0 {
37 %0 = load i32 ()*, i32 ()** @direct_address, align 8
42 define hidden i32 @call_alias_ptr() #0 {
44 %0 = load i32 ()*, i32 ()** @alias_address, align 8
50 ; CHECK-NEXT: Signatures:
51 ; CHECK-NEXT: - Index: 0
52 ; CHECK-NEXT: ReturnType: I32
53 ; CHECK-NEXT: ParamTypes:
54 ; CHECK-NEXT: - Type: IMPORT
55 ; CHECK-NEXT: Imports:
56 ; CHECK-NEXT: - Module: env
57 ; CHECK-NEXT: Field: __linear_memory
58 ; CHECK-NEXT: Kind: MEMORY
60 ; CHECK-NEXT: Initial: 0x00000001
61 ; CHECK-NEXT: - Module: env
62 ; CHECK-NEXT: Field: __indirect_function_table
63 ; CHECK-NEXT: Kind: TABLE
65 ; CHECK-NEXT: ElemType: FUNCREF
67 ; CHECK-NEXT: Initial: 0x00000001
68 ; CHECK-NEXT: - Type: FUNCTION
69 ; CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 0, 0 ]
70 ; CHECK-NEXT: - Type: ELEM
71 ; CHECK-NEXT: Segments:
72 ; CHECK-NEXT: - Offset:
73 ; CHECK-NEXT: Opcode: I32_CONST
74 ; CHECK-NEXT: Value: 1
75 ; CHECK-NEXT: Functions: [ 0 ]
76 ; CHECK-NEXT: - Type: DATACOUNT
77 ; CHECK-NEXT: Count: 3
78 ; CHECK-NEXT: - Type: CODE
79 ; CHECK-NEXT: Relocations:
80 ; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
81 ; CHECK-NEXT: Index: 0
82 ; CHECK-NEXT: Offset: 0x00000009
83 ; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
84 ; CHECK-NEXT: Index: 3
85 ; CHECK-NEXT: Offset: 0x00000012
86 ; CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB
87 ; CHECK-NEXT: Index: 5
88 ; CHECK-NEXT: Offset: 0x0000001E
89 ; CHECK-NEXT: - Type: R_WASM_TYPE_INDEX_LEB
90 ; CHECK-NEXT: Index: 0
91 ; CHECK-NEXT: Offset: 0x00000024
92 ; CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB
93 ; CHECK-NEXT: Index: 7
94 ; CHECK-NEXT: Offset: 0x00000031
95 ; CHECK-NEXT: - Type: R_WASM_TYPE_INDEX_LEB
96 ; CHECK-NEXT: Index: 0
97 ; CHECK-NEXT: Offset: 0x00000037
98 ; CHECK-NEXT: Functions:
99 ; CHECK-NEXT: - Index: 0
100 ; CHECK-NEXT: Locals:
101 ; CHECK-NEXT: Body: 41000B
102 ; CHECK-NEXT: - Index: 1
103 ; CHECK-NEXT: Locals:
104 ; CHECK-NEXT: Body: 1080808080000B
105 ; CHECK-NEXT: - Index: 2
106 ; CHECK-NEXT: Locals:
107 ; CHECK-NEXT: Body: 1080808080000B
108 ; CHECK-NEXT: - Index: 3
109 ; CHECK-NEXT: Locals:
110 ; CHECK-NEXT: Body: 410028028880808000118080808000000B
111 ; CHECK-NEXT: - Index: 4
112 ; CHECK-NEXT: Locals:
113 ; CHECK-NEXT: Body: 410028029080808000118080808000000B
114 ; CHECK-NEXT: - Type: DATA
115 ; CHECK-NEXT: Relocations:
116 ; CHECK-NEXT: - Type: R_WASM_TABLE_INDEX_I32
117 ; CHECK-NEXT: Index: 0
118 ; CHECK-NEXT: Offset: 0x0000000F
119 ; CHECK-NEXT: - Type: R_WASM_TABLE_INDEX_I32
120 ; CHECK-NEXT: Index: 3
121 ; CHECK-NEXT: Offset: 0x00000018
122 ; CHECK-NEXT: Segments:
123 ; CHECK-NEXT: - SectionOffset: 6
124 ; CHECK-NEXT: InitFlags: 0
125 ; CHECK-NEXT: Offset:
126 ; CHECK-NEXT: Opcode: I32_CONST
127 ; CHECK-NEXT: Value: 0
128 ; CHECK-NEXT: Content: '07000000'
129 ; CHECK-NEXT: - SectionOffset: 15
130 ; CHECK-NEXT: InitFlags: 0
131 ; CHECK-NEXT: Offset:
132 ; CHECK-NEXT: Opcode: I32_CONST
133 ; CHECK-NEXT: Value: 8
134 ; CHECK-NEXT: Content: '01000000'
135 ; CHECK-NEXT: - SectionOffset: 24
136 ; CHECK-NEXT: InitFlags: 0
137 ; CHECK-NEXT: Offset:
138 ; CHECK-NEXT: Opcode: I32_CONST
139 ; CHECK-NEXT: Value: 16
140 ; CHECK-NEXT: Content: '01000000'
141 ; CHECK-NEXT: - Type: CUSTOM
142 ; CHECK-NEXT: Name: linking
143 ; CHECK-NEXT: Version: 2
144 ; CHECK-NEXT: SymbolTable:
145 ; CHECK-NEXT: - Index: 0
146 ; CHECK-NEXT: Kind: FUNCTION
147 ; CHECK-NEXT: Name: foo
148 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
149 ; CHECK-NEXT: Function: 0
150 ; CHECK-NEXT: - Index: 1
151 ; CHECK-NEXT: Kind: FUNCTION
152 ; CHECK-NEXT: Name: call_direct
153 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
154 ; CHECK-NEXT: Function: 1
155 ; CHECK-NEXT: - Index: 2
156 ; CHECK-NEXT: Kind: FUNCTION
157 ; CHECK-NEXT: Name: call_alias
158 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
159 ; CHECK-NEXT: Function: 2
160 ; CHECK-NEXT: - Index: 3
161 ; CHECK-NEXT: Kind: FUNCTION
162 ; CHECK-NEXT: Name: foo_alias
163 ; CHECK-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ]
164 ; CHECK-NEXT: Function: 0
165 ; CHECK-NEXT: - Index: 4
166 ; CHECK-NEXT: Kind: FUNCTION
167 ; CHECK-NEXT: Name: call_direct_ptr
168 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
169 ; CHECK-NEXT: Function: 3
170 ; CHECK-NEXT: - Index: 5
171 ; CHECK-NEXT: Kind: DATA
172 ; CHECK-NEXT: Name: direct_address
173 ; CHECK-NEXT: Flags: [ ]
174 ; CHECK-NEXT: Segment: 1
175 ; CHECK-NEXT: Size: 4
176 ; CHECK-NEXT: - Index: 6
177 ; CHECK-NEXT: Kind: FUNCTION
178 ; CHECK-NEXT: Name: call_alias_ptr
179 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
180 ; CHECK-NEXT: Function: 4
181 ; CHECK-NEXT: - Index: 7
182 ; CHECK-NEXT: Kind: DATA
183 ; CHECK-NEXT: Name: alias_address
184 ; CHECK-NEXT: Flags: [ ]
185 ; CHECK-NEXT: Segment: 2
186 ; CHECK-NEXT: Size: 4
187 ; CHECK-NEXT: - Index: 8
188 ; CHECK-NEXT: Kind: DATA
189 ; CHECK-NEXT: Name: bar
190 ; CHECK-NEXT: Flags: [ ]
191 ; CHECK-NEXT: Segment: 0
192 ; CHECK-NEXT: Size: 4
193 ; CHECK-NEXT: - Index: 9
194 ; CHECK-NEXT: Kind: DATA
195 ; CHECK-NEXT: Name: bar_alias
196 ; CHECK-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ]
197 ; CHECK-NEXT: Segment: 0
198 ; CHECK-NEXT: Size: 4
199 ; CHECK-NEXT: SegmentInfo:
200 ; CHECK-NEXT: - Index: 0
201 ; CHECK-NEXT: Name: .data.bar
202 ; CHECK-NEXT: Alignment: 3
203 ; CHECK-NEXT: Flags: [ ]
204 ; CHECK-NEXT: - Index: 1
205 ; CHECK-NEXT: Name: .data.direct_address
206 ; CHECK-NEXT: Alignment: 3
207 ; CHECK-NEXT: Flags: [ ]
208 ; CHECK-NEXT: - Index: 2
209 ; CHECK-NEXT: Name: .data.alias_address
210 ; CHECK-NEXT: Alignment: 3
211 ; CHECK-NEXT: Flags: [ ]
214 ; CHECK-SYMS: SYMBOL TABLE:
215 ; CHECK-SYMS-NEXT: 00000001 g F CODE .hidden foo
216 ; CHECK-SYMS-NEXT: 00000006 g F CODE .hidden call_direct
217 ; CHECK-SYMS-NEXT: 0000000f g F CODE .hidden call_alias
218 ; CHECK-SYMS-NEXT: 00000001 gw F CODE .hidden foo_alias
219 ; CHECK-SYMS-NEXT: 00000018 g F CODE .hidden call_direct_ptr
220 ; CHECK-SYMS-NEXT: 00000008 g O DATA direct_address
221 ; CHECK-SYMS-NEXT: 0000002b g F CODE .hidden call_alias_ptr
222 ; CHECK-SYMS-NEXT: 00000010 g O DATA alias_address
223 ; CHECK-SYMS-NEXT: 00000000 g O DATA bar
224 ; CHECK-SYMS-NEXT: 00000000 gw O DATA .hidden bar_alias