1 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/call-indirect.s -o %t2.o
3 # RUN: wasm-ld --export-dynamic -o %t.wasm %t2.o %t.o
4 # RUN: obj2yaml %t.wasm | FileCheck %s
8 .functype foo () -> (i32)
14 .functype _start () -> ()
16 i32.load indirect_func
17 call_indirect
() -> (i32
)
21 # Indirect function call where no function actually has this type.
22 # Ensures that the type entry is still created in this case.
26 .functype call_ptr (i32) -> ()
29 call_indirect
(i64
) -> (i64
)
34 .section .data.indirect_func,"",@
37 .size indirect_func, 4
40 # CHECK-NEXT: FileHeader:
41 # CHECK-NEXT: Version: 0x1
42 # CHECK-NEXT: Sections:
43 # CHECK-NEXT: - Type: TYPE
44 # CHECK-NEXT: Signatures:
45 # CHECK-NEXT: - Index: 0
46 # CHECK-NEXT: ParamTypes:
47 # CHECK-NEXT: ReturnTypes:
49 # CHECK-NEXT: - Index: 1
50 # CHECK-NEXT: ParamTypes:
51 # CHECK-NEXT: ReturnTypes:
53 # CHECK-NEXT: - Index: 2
54 # CHECK-NEXT: ParamTypes:
56 # CHECK-NEXT: ReturnTypes:
58 # CHECK-NEXT: - Index: 3
59 # CHECK-NEXT: ParamTypes:
60 # CHECK-NEXT: ReturnTypes: []
61 # CHECK-NEXT: - Index: 4
62 # CHECK-NEXT: ParamTypes:
64 # CHECK-NEXT: ReturnTypes: []
65 # CHECK-NEXT: - Type: FUNCTION
66 # CHECK-NEXT: FunctionTypes: [ 0, 3, 1, 3, 4 ]
67 # CHECK-NEXT: - Type: TABLE
69 # CHECK-NEXT: - Index: 0
70 # CHECK-NEXT: ElemType: FUNCREF
72 # CHECK-NEXT: Flags: [ HAS_MAX ]
73 # CHECK-NEXT: Minimum: 0x3
74 # CHECK-NEXT: Maximum: 0x3
75 # CHECK-NEXT: - Type: MEMORY
76 # CHECK-NEXT: Memories:
77 # CHECK-NEXT: - Minimum: 0x2
78 # CHECK-NEXT: - Type: GLOBAL
79 # CHECK-NEXT: Globals:
80 # CHECK-NEXT: - Index: 0
81 # CHECK-NEXT: Type: I32
82 # CHECK-NEXT: Mutable: true
83 # CHECK-NEXT: InitExpr:
84 # CHECK-NEXT: Opcode: I32_CONST
85 # CHECK-NEXT: Value: 66576
86 # CHECK-NEXT: - Index: 1
87 # CHECK-NEXT: Type: I32
88 # CHECK-NEXT: Mutable: false
89 # CHECK-NEXT: InitExpr:
90 # CHECK-NEXT: Opcode: I32_CONST
91 # CHECK-NEXT: Value: 1032
92 # CHECK-NEXT: - Type: EXPORT
93 # CHECK-NEXT: Exports:
94 # CHECK-NEXT: - Name: memory
95 # CHECK-NEXT: Kind: MEMORY
96 # CHECK-NEXT: Index: 0
97 # CHECK-NEXT: - Name: bar
98 # CHECK-NEXT: Kind: FUNCTION
99 # CHECK-NEXT: Index: 0
100 # CHECK-NEXT: - Name: call_bar_indirect
101 # CHECK-NEXT: Kind: FUNCTION
102 # CHECK-NEXT: Index: 1
103 # CHECK-NEXT: - Name: foo
104 # CHECK-NEXT: Kind: FUNCTION
105 # CHECK-NEXT: Index: 2
106 # CHECK-NEXT: - Name: _start
107 # CHECK-NEXT: Kind: FUNCTION
108 # CHECK-NEXT: Index: 3
109 # CHECK-NEXT: - Name: indirect_func
110 # CHECK-NEXT: Kind: GLOBAL
111 # CHECK-NEXT: Index: 1
112 # CHECK-NEXT: - Name: call_ptr
113 # CHECK-NEXT: Kind: FUNCTION
114 # CHECK-NEXT: Index: 4
115 # CHECK-NEXT: - Type: ELEM
116 # CHECK-NEXT: Segments:
117 # CHECK-NEXT: - Offset:
118 # CHECK-NEXT: Opcode: I32_CONST
119 # CHECK-NEXT: Value: 1
120 # CHECK-NEXT: Functions: [ 0, 2 ]
121 # CHECK-NEXT: - Type: CODE
122 # CHECK-NEXT: Functions:
123 # CHECK-NEXT: - Index: 0
124 # CHECK-NEXT: Locals:
125 # CHECK-NEXT: Body: 42010B
126 # CHECK-NEXT: - Index: 1
127 # CHECK-NEXT: Locals:
128 # CHECK-NEXT: Body: 410028028088808000118080808000001A410028028488808000118180808000001A0B
129 # CHECK-NEXT: - Index: 2
130 # CHECK-NEXT: Locals:
131 # CHECK-NEXT: Body: 41020B
132 # CHECK-NEXT: - Index: 3
133 # CHECK-NEXT: Locals:
134 # CHECK-NEXT: Body: 410028028888808000118180808000001A0B
135 # CHECK-NEXT: - Index: 4
136 # CHECK-NEXT: Locals:
137 # CHECK-NEXT: Body: 42012000118280808000001A0B
138 # CHECK-NEXT: - Type: DATA
139 # CHECK-NEXT: Segments:
140 # CHECK-NEXT: - SectionOffset: 7
141 # CHECK-NEXT: InitFlags: 0
142 # CHECK-NEXT: Offset:
143 # CHECK-NEXT: Opcode: I32_CONST
144 # CHECK-NEXT: Value: 1024
145 # CHECK-NEXT: Content: '010000000200000002000000'
146 # CHECK-NEXT: - Type: CUSTOM
147 # CHECK-NEXT: Name: name
148 # CHECK-NEXT: FunctionNames:
149 # CHECK-NEXT: - Index: 0
150 # CHECK-NEXT: Name: bar
151 # CHECK-NEXT: - Index: 1
152 # CHECK-NEXT: Name: call_bar_indirect
153 # CHECK-NEXT: - Index: 2
154 # CHECK-NEXT: Name: foo
155 # CHECK-NEXT: - Index: 3
156 # CHECK-NEXT: Name: _start
157 # CHECK-NEXT: - Index: 4
158 # CHECK-NEXT: Name: call_ptr
159 # CHECK-NEXT: GlobalNames:
160 # CHECK-NEXT: - Index: 0
161 # CHECK-NEXT: Name: __stack_pointer
162 # CHECK-NEXT: DataSegmentNames:
163 # CHECK-NEXT: - Index: 0
164 # CHECK-NEXT: Name: .data