1 # RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj < %s | obj2yaml | FileCheck %s
3 # Verify that @GOT relocation entryes result in R_WASM_GLOBAL_INDEX_LEB against
4 # against the corrsponding function or data symbol and that the corresponding
5 # data symbols are imported as a wasm globals.
8 .functype load_default_data () -> (i32)
9 global.get default_data@GOT
14 .functype load_default_func () -> (i32)
15 global.get default_func@GOT
20 .functype load_hidden_data () -> (i32)
21 global.get __memory_base
22 i32.const
.L.hidden_data@MBREL
27 .functype load_hidden_func () -> (i32)
28 global.get __table_base
29 i32.const hidden_func@TBREL
34 .functype hidden_func () -> (i32)
38 .section .rodata.hidden_data,"",@
41 .size .L.hidden_data, 1
46 .functype default_func () -> (i32)
49 # CHECK-NEXT: FileHeader:
50 # CHECK-NEXT: Version: 0x00000001
51 # CHECK-NEXT: Sections:
52 # CHECK-NEXT: - Type: TYPE
53 # CHECK-NEXT: Signatures:
54 # CHECK-NEXT: - Index: 0
55 # CHECK-NEXT: ReturnType: I32
56 # CHECK-NEXT: ParamTypes: []
57 # CHECK-NEXT: - Type: IMPORT
58 # CHECK-NEXT: Imports:
59 # CHECK-NEXT: - Module: env
60 # CHECK-NEXT: Field: __linear_memory
61 # CHECK-NEXT: Kind: MEMORY
63 # CHECK-NEXT: Initial: 0x00000001
64 # CHECK-NEXT: - Module: env
65 # CHECK-NEXT: Field: __indirect_function_table
66 # CHECK-NEXT: Kind: TABLE
68 # CHECK-NEXT: ElemType: FUNCREF
70 # CHECK-NEXT: Initial: 0x00000000
71 # CHECK-NEXT: - Module: env
72 # CHECK-NEXT: Field: default_func
73 # CHECK-NEXT: Kind: FUNCTION
74 # CHECK-NEXT: SigIndex: 0
75 # CHECK-NEXT: - Module: GOT.mem
76 # CHECK-NEXT: Field: default_data
77 # CHECK-NEXT: Kind: GLOBAL
78 # CHECK-NEXT: GlobalType: I32
79 # CHECK-NEXT: GlobalMutable: true
80 # CHECK-NEXT: - Module: GOT.func
81 # CHECK-NEXT: Field: default_func
82 # CHECK-NEXT: Kind: GLOBAL
83 # CHECK-NEXT: GlobalType: I32
84 # CHECK-NEXT: GlobalMutable: true
85 # CHECK-NEXT: - Type: FUNCTION
86 # CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 0, 0 ]
87 # CHECK-NEXT: - Type: DATACOUNT
88 # CHECK-NEXT: Count: 1
89 # CHECK-NEXT: - Type: CODE
90 # CHECK-NEXT: Relocations:
91 # CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
92 # CHECK-NEXT: Index: 1
93 # CHECK-NEXT: Offset: 0x00000004
94 # CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
95 # CHECK-NEXT: Index: 3
96 # CHECK-NEXT: Offset: 0x00000010
97 # CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB
98 # CHECK-NEXT: Index: 5
99 # CHECK-NEXT: Offset: 0x0000001C
100 # CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_REL_SLEB
101 # CHECK-NEXT: Index: 6
102 # CHECK-NEXT: Offset: 0x00000022
103 # CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB
104 # CHECK-NEXT: Index: 8
105 # CHECK-NEXT: Offset: 0x0000002C
106 # CHECK-NEXT: - Type: R_WASM_TABLE_INDEX_REL_SLEB
107 # CHECK-NEXT: Index: 9
108 # CHECK-NEXT: Offset: 0x00000032
109 # CHECK-NEXT: Functions:
110 # CHECK-NEXT: - Index: 1
111 # CHECK-NEXT: Locals: []
112 # CHECK-NEXT: Body: 2380808080002802000B
113 # CHECK-NEXT: - Index: 2
114 # CHECK-NEXT: Locals: []
115 # CHECK-NEXT: Body: 2381808080002802000B
116 # CHECK-NEXT: - Index: 3
117 # CHECK-NEXT: Locals: []
118 # CHECK-NEXT: Body: 2380808080004180808080006A0B
119 # CHECK-NEXT: - Index: 4
120 # CHECK-NEXT: Locals: []
121 # CHECK-NEXT: Body: 2380808080004180808080006A0B
122 # CHECK-NEXT: - Index: 5
123 # CHECK-NEXT: Locals: []
124 # CHECK-NEXT: Body: 41000B
125 # CHECK-NEXT: - Type: DATA
126 # CHECK-NEXT: Segments:
127 # CHECK-NEXT: - SectionOffset: 6
128 # CHECK-NEXT: InitFlags: 0
129 # CHECK-NEXT: Offset:
130 # CHECK-NEXT: Opcode: I32_CONST
131 # CHECK-NEXT: Value: 0
132 # CHECK-NEXT: Content: '64'
133 # CHECK-NEXT: - Type: CUSTOM
134 # CHECK-NEXT: Name: linking
135 # CHECK-NEXT: Version: 2
136 # CHECK-NEXT: SymbolTable:
137 # CHECK-NEXT: - Index: 0
138 # CHECK-NEXT: Kind: FUNCTION
139 # CHECK-NEXT: Name: load_default_data
140 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
141 # CHECK-NEXT: Function: 1
142 # CHECK-NEXT: - Index: 1
143 # CHECK-NEXT: Kind: DATA
144 # CHECK-NEXT: Name: default_data
145 # CHECK-NEXT: Flags: [ UNDEFINED ]
146 # CHECK-NEXT: - Index: 2
147 # CHECK-NEXT: Kind: FUNCTION
148 # CHECK-NEXT: Name: load_default_func
149 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
150 # CHECK-NEXT: Function: 2
151 # CHECK-NEXT: - Index: 3
152 # CHECK-NEXT: Kind: FUNCTION
153 # CHECK-NEXT: Name: default_func
154 # CHECK-NEXT: Flags: [ UNDEFINED ]
155 # CHECK-NEXT: Function: 0
156 # CHECK-NEXT: - Index: 4
157 # CHECK-NEXT: Kind: FUNCTION
158 # CHECK-NEXT: Name: load_hidden_data
159 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
160 # CHECK-NEXT: Function: 3
161 # CHECK-NEXT: - Index: 5
162 # CHECK-NEXT: Kind: DATA
163 # CHECK-NEXT: Name: __memory_base
164 # CHECK-NEXT: Flags: [ UNDEFINED ]
165 # CHECK-NEXT: - Index: 6
166 # CHECK-NEXT: Kind: DATA
167 # CHECK-NEXT: Name: .L.hidden_data
168 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
169 # CHECK-NEXT: Segment: 0
170 # CHECK-NEXT: Size: 1
171 # CHECK-NEXT: - Index: 7
172 # CHECK-NEXT: Kind: FUNCTION
173 # CHECK-NEXT: Name: load_hidden_func
174 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
175 # CHECK-NEXT: Function: 4
176 # CHECK-NEXT: - Index: 8
177 # CHECK-NEXT: Kind: DATA
178 # CHECK-NEXT: Name: __table_base
179 # CHECK-NEXT: Flags: [ UNDEFINED ]
180 # CHECK-NEXT: - Index: 9
181 # CHECK-NEXT: Kind: FUNCTION
182 # CHECK-NEXT: Name: hidden_func
183 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
184 # CHECK-NEXT: Function: 5
185 # CHECK-NEXT: SegmentInfo:
186 # CHECK-NEXT: - Index: 0
187 # CHECK-NEXT: Name: .rodata.hidden_data
188 # CHECK-NEXT: Alignment: 0
189 # CHECK-NEXT: Flags: [ ]