• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o %t.o < %s
2# RUN: obj2yaml %t.o | FileCheck %s
3
4# 'foo_alias()' is weak alias of function 'foo()'
5# 'bar_alias' is weak alias of global variable 'bar'
6# Generates two exports of the same function, one of them weak
7
8foo:
9  .hidden foo
10  .globl  foo
11  .functype foo () -> (i32)
12  i32.const 0
13  end_function
14
15call_direct:
16  .hidden call_direct
17  .globl call_direct
18  .functype call_direct () -> (i32)
19  call foo
20  end_function
21
22call_alias:
23  .hidden call_alias
24  .globl call_alias
25  .functype call_alias () -> (i32)
26  call foo_alias
27  end_function
28
29call_direct_ptr:
30  .hidden call_direct_ptr
31  .globl call_direct_ptr
32  .functype call_direct_ptr () -> (i32)
33  i32.const 0
34  i32.load direct_address
35  call_indirect () -> (i32)
36  end_function
37
38call_alias_ptr:
39  .hidden call_alias_ptr
40  .globl call_alias_ptr
41  .functype call_alias_ptr () -> (i32)
42  i32.const 0
43  i32.load alias_address
44  call_indirect () -> (i32)
45  end_function
46
47.section .data.bar,"",@
48bar:
49  .int32   7
50  .size    bar, 4
51  .globl   bar
52  .p2align 3
53
54.section .data.direct_address,"",@
55direct_address:
56  .int32 foo
57  .size  direct_address, 4
58  .globl direct_address
59  .p2align 3
60
61.section .data.alias_address,"",@
62alias_address:
63  .int32 foo_alias
64  .size  alias_address, 4
65  .globl alias_address
66  .p2align 3
67
68# Define Aliases
69.set foo_alias, foo
70  .weak   foo_alias
71  .type   foo_alias,@function
72  .hidden foo_alias
73
74.set bar_alias, bar
75  .weak   bar_alias
76  .hidden bar_alias
77
78# CHECK:        - Type:            TYPE
79# CHECK-NEXT:     Signatures:
80# CHECK-NEXT:       - Index:           0
81# CHECK-NEXT:         ParamTypes:
82# CHECK-NEXT:         ReturnTypes:
83# CHECK-NEXT:           - I32
84# CHECK-NEXT:   - Type:            IMPORT
85# CHECK-NEXT:     Imports:
86# CHECK-NEXT:       - Module:          env
87# CHECK-NEXT:         Field:           __linear_memory
88# CHECK-NEXT:         Kind:            MEMORY
89# CHECK-NEXT:         Memory:
90# CHECK-NEXT:           Initial:         0x1
91# CHECK-NEXT:       - Module:          env
92# CHECK-NEXT:         Field:           __indirect_function_table
93# CHECK-NEXT:         Kind:            TABLE
94# CHECK-NEXT:         Table:
95# CHECK-NEXT:           Index:           0
96# CHECK-NEXT:           ElemType:        FUNCREF
97# CHECK-NEXT:           Limits:
98# CHECK-NEXT:             Initial:         0x1
99# CHECK-NEXT:   - Type:            FUNCTION
100# CHECK-NEXT:     FunctionTypes:   [ 0, 0, 0, 0, 0 ]
101# CHECK-NEXT:   - Type:            ELEM
102# CHECK-NEXT:     Segments:
103# CHECK-NEXT:       - Offset:
104# CHECK-NEXT:           Opcode:          I32_CONST
105# CHECK-NEXT:           Value:           1
106# CHECK-NEXT:         Functions:       [ 0 ]
107# CHECK-NEXT:   - Type:            DATACOUNT
108# CHECK-NEXT:     Count:           3
109# CHECK-NEXT:   - Type:            CODE
110# CHECK-NEXT:     Relocations:
111# CHECK-NEXT:       - Type:            R_WASM_FUNCTION_INDEX_LEB
112# CHECK-NEXT:         Index:           0
113# CHECK-NEXT:         Offset:          0x9
114# CHECK-NEXT:       - Type:            R_WASM_FUNCTION_INDEX_LEB
115# CHECK-NEXT:         Index:           3
116# CHECK-NEXT:         Offset:          0x12
117# CHECK-NEXT:       - Type:            R_WASM_MEMORY_ADDR_LEB
118# CHECK-NEXT:         Index:           5
119# CHECK-NEXT:         Offset:          0x1E
120# CHECK-NEXT:       - Type:            R_WASM_TYPE_INDEX_LEB
121# CHECK-NEXT:         Index:           0
122# CHECK-NEXT:         Offset:          0x24
123# CHECK-NEXT:       - Type:            R_WASM_MEMORY_ADDR_LEB
124# CHECK-NEXT:         Index:           7
125# CHECK-NEXT:         Offset:          0x31
126# CHECK-NEXT:       - Type:            R_WASM_TYPE_INDEX_LEB
127# CHECK-NEXT:         Index:           0
128# CHECK-NEXT:         Offset:          0x37
129# CHECK-NEXT:     Functions:
130# CHECK-NEXT:       - Index:           0
131# CHECK-NEXT:         Locals:
132# CHECK-NEXT:         Body:            41000B
133# CHECK-NEXT:       - Index:           1
134# CHECK-NEXT:         Locals:
135# CHECK-NEXT:         Body:            1080808080000B
136# CHECK-NEXT:       - Index:           2
137# CHECK-NEXT:         Locals:
138# CHECK-NEXT:         Body:            1080808080000B
139# CHECK-NEXT:       - Index:           3
140# CHECK-NEXT:         Locals:
141# CHECK-NEXT:         Body:            410028028880808000118080808000000B
142# CHECK-NEXT:       - Index:           4
143# CHECK-NEXT:         Locals:
144# CHECK-NEXT:         Body:            410028029080808000118080808000000B
145# CHECK-NEXT:   - Type:            DATA
146# CHECK-NEXT:     Relocations:
147# CHECK-NEXT:       - Type:            R_WASM_TABLE_INDEX_I32
148# CHECK-NEXT:         Index:           0
149# CHECK-NEXT:         Offset:          0x13
150# CHECK-NEXT:       - Type:            R_WASM_TABLE_INDEX_I32
151# CHECK-NEXT:         Index:           3
152# CHECK-NEXT:         Offset:          0x20
153# CHECK-NEXT:     Segments:
154# CHECK-NEXT:       - SectionOffset:   6
155# CHECK-NEXT:         InitFlags:       0
156# CHECK-NEXT:         Offset:
157# CHECK-NEXT:           Opcode:          I32_CONST
158# CHECK-NEXT:           Value:           0
159# CHECK-NEXT:         Content:         '0700000000000000'
160# CHECK-NEXT:       - SectionOffset:   19
161# CHECK-NEXT:         InitFlags:       0
162# CHECK-NEXT:         Offset:
163# CHECK-NEXT:           Opcode:          I32_CONST
164# CHECK-NEXT:           Value:           8
165# CHECK-NEXT:         Content:         '0100000000000000'
166# CHECK-NEXT:       - SectionOffset:   32
167# CHECK-NEXT:         InitFlags:       0
168# CHECK-NEXT:         Offset:
169# CHECK-NEXT:           Opcode:          I32_CONST
170# CHECK-NEXT:           Value:           16
171# CHECK-NEXT:         Content:         '0100000000000000'
172# CHECK-NEXT:   - Type:            CUSTOM
173# CHECK-NEXT:     Name:            linking
174# CHECK-NEXT:     Version:         2
175# CHECK-NEXT:     SymbolTable:
176# CHECK-NEXT:       - Index:           0
177# CHECK-NEXT:         Kind:            FUNCTION
178# CHECK-NEXT:         Name:            foo
179# CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
180# CHECK-NEXT:         Function:        0
181# CHECK-NEXT:       - Index:           1
182# CHECK-NEXT:         Kind:            FUNCTION
183# CHECK-NEXT:         Name:            call_direct
184# CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
185# CHECK-NEXT:         Function:        1
186# CHECK-NEXT:       - Index:           2
187# CHECK-NEXT:         Kind:            FUNCTION
188# CHECK-NEXT:         Name:            call_alias
189# CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
190# CHECK-NEXT:         Function:        2
191# CHECK-NEXT:       - Index:           3
192# CHECK-NEXT:         Kind:            FUNCTION
193# CHECK-NEXT:         Name:            foo_alias
194# CHECK-NEXT:         Flags:           [ BINDING_WEAK, VISIBILITY_HIDDEN, NO_STRIP ]
195# CHECK-NEXT:         Function:        0
196# CHECK-NEXT:       - Index:           4
197# CHECK-NEXT:         Kind:            FUNCTION
198# CHECK-NEXT:         Name:            call_direct_ptr
199# CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
200# CHECK-NEXT:         Function:        3
201# CHECK-NEXT:       - Index:           5
202# CHECK-NEXT:         Kind:            DATA
203# CHECK-NEXT:         Name:            direct_address
204# CHECK-NEXT:         Flags:           [  ]
205# CHECK-NEXT:         Segment:         1
206# CHECK-NEXT:         Size:            4
207# CHECK-NEXT:       - Index:           6
208# CHECK-NEXT:         Kind:            FUNCTION
209# CHECK-NEXT:         Name:            call_alias_ptr
210# CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
211# CHECK-NEXT:         Function:        4
212# CHECK-NEXT:       - Index:           7
213# CHECK-NEXT:         Kind:            DATA
214# CHECK-NEXT:         Name:            alias_address
215# CHECK-NEXT:         Flags:           [  ]
216# CHECK-NEXT:         Segment:         2
217# CHECK-NEXT:         Size:            4
218# CHECK-NEXT:       - Index:           8
219# CHECK-NEXT:         Kind:            DATA
220# CHECK-NEXT:         Name:            bar
221# CHECK-NEXT:         Flags:           [  ]
222# CHECK-NEXT:         Segment:         0
223# CHECK-NEXT:         Size:            4
224# CHECK-NEXT:       - Index:           9
225# CHECK-NEXT:         Kind:            DATA
226# CHECK-NEXT:         Name:            bar_alias
227# CHECK-NEXT:         Flags:           [ BINDING_WEAK, VISIBILITY_HIDDEN, NO_STRIP ]
228# CHECK-NEXT:         Segment:         0
229# CHECK-NEXT:         Size:            4
230# CHECK-NEXT:     SegmentInfo:
231# CHECK-NEXT:       - Index:           0
232# CHECK-NEXT:         Name:            .data.bar
233# CHECK-NEXT:         Alignment:       3
234# CHECK-NEXT:         Flags:           [ ]
235# CHECK-NEXT:       - Index:           1
236# CHECK-NEXT:         Name:            .data.direct_address
237# CHECK-NEXT:         Alignment:       3
238# CHECK-NEXT:         Flags:           [ ]
239# CHECK-NEXT:       - Index:           2
240# CHECK-NEXT:         Name:            .data.alias_address
241# CHECK-NEXT:         Alignment:       3
242# CHECK-NEXT:         Flags:           [ ]
243# CHECK-NEXT: ...
244
245# CHECK-SYMS: SYMBOL TABLE:
246# CHECK-SYMS-NEXT: 00000001 g     F CODE	.hidden foo
247# CHECK-SYMS-NEXT: 00000006 g     F CODE	.hidden call_direct
248# CHECK-SYMS-NEXT: 0000000f g     F CODE	.hidden call_alias
249# CHECK-SYMS-NEXT: 00000001 gw    F CODE	.hidden foo_alias
250# CHECK-SYMS-NEXT: 00000018 g     F CODE	.hidden call_direct_ptr
251# CHECK-SYMS-NEXT: 00000008 g     O DATA	direct_address
252# CHECK-SYMS-NEXT: 0000002b g     F CODE	.hidden call_alias_ptr
253# CHECK-SYMS-NEXT: 00000010 g     O DATA	alias_address
254# CHECK-SYMS-NEXT: 00000000 g     O DATA	bar
255# CHECK-SYMS-NEXT: 00000000 gw    O DATA	.hidden bar_alias
256