• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj < %s | obj2yaml | FileCheck %s
2
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.
6
7load_default_data:
8    .functype   load_default_data () -> (i32)
9    global.get  default_data@GOT
10    i32.load    0
11    end_function
12
13load_default_func:
14    .functype   load_default_func () -> (i32)
15    global.get  default_func@GOT
16    i32.load    0
17    end_function
18
19load_hidden_data:
20    .functype   load_hidden_data () -> (i32)
21    global.get  __memory_base
22    i32.const   .L.hidden_data@MBREL
23    i32.add
24    end_function
25
26load_hidden_func:
27    .functype   load_hidden_func () -> (i32)
28    global.get  __table_base
29    i32.const   hidden_func@TBREL
30    i32.add
31    end_function
32
33hidden_func:
34    .functype   hidden_func () -> (i32)
35    i32.const 0
36    end_function
37
38.section .rodata.hidden_data,"",@
39.L.hidden_data:
40    .int8 100
41    .size .L.hidden_data, 1
42
43#.hidden hidden_func
44#.hidden hidden_data
45.size default_data, 4
46.functype default_func () -> (i32)
47
48# CHECK:      --- !WASM
49# CHECK-NEXT: FileHeader:
50# CHECK-NEXT:   Version:         0x1
51# CHECK-NEXT: Sections:
52# CHECK-NEXT:   - Type:            TYPE
53# CHECK-NEXT:     Signatures:
54# CHECK-NEXT:       - Index:           0
55# CHECK-NEXT:         ParamTypes:      []
56# CHECK-NEXT:         ReturnTypes:
57# CHECK-NEXT:           - I32
58# CHECK-NEXT:   - Type:            IMPORT
59# CHECK-NEXT:     Imports:
60# CHECK-NEXT:       - Module:          env
61# CHECK-NEXT:         Field:           __linear_memory
62# CHECK-NEXT:         Kind:            MEMORY
63# CHECK-NEXT:         Memory:
64# CHECK-NEXT:           Initial:         0x1
65# CHECK-NEXT:       - Module:          env
66# CHECK-NEXT:         Field:           default_func
67# CHECK-NEXT:         Kind:            FUNCTION
68# CHECK-NEXT:         SigIndex:        0
69# CHECK-NEXT:       - Module:          env
70# CHECK-NEXT:         Field:           __indirect_function_table
71# CHECK-NEXT:         Kind:            TABLE
72# CHECK-NEXT:         Table:
73# CHECK-NEXT:           Index:           0
74# CHECK-NEXT:           ElemType:        FUNCREF
75# CHECK-NEXT:           Limits:
76# CHECK-NEXT:             Initial:         0x1
77# CHECK-NEXT:       - Module:          GOT.mem
78# CHECK-NEXT:         Field:           default_data
79# CHECK-NEXT:         Kind:            GLOBAL
80# CHECK-NEXT:         GlobalType:      I32
81# CHECK-NEXT:         GlobalMutable:   true
82# CHECK-NEXT:       - Module:          GOT.func
83# CHECK-NEXT:         Field:           default_func
84# CHECK-NEXT:         Kind:            GLOBAL
85# CHECK-NEXT:         GlobalType:      I32
86# CHECK-NEXT:         GlobalMutable:   true
87# CHECK-NEXT:   - Type:            FUNCTION
88# CHECK-NEXT:     FunctionTypes:   [ 0, 0, 0, 0, 0 ]
89# CHECK-NEXT:   - Type:            ELEM
90# CHECK-NEXT:     Segments:
91# CHECK-NEXT:        Offset:
92# CHECK-NEXT:          Opcode:          I32_CONST
93# CHECK-NEXT:          Value:           1
94# CHECK-NEXT:        Functions:       [ 5 ]
95# CHECK-NEXT:   - Type:            DATACOUNT
96# CHECK-NEXT:     Count:           1
97# CHECK-NEXT:   - Type:            CODE
98# CHECK-NEXT:     Relocations:
99# CHECK-NEXT:       - Type:            R_WASM_GLOBAL_INDEX_LEB
100# CHECK-NEXT:         Index:           1
101# CHECK-NEXT:         Offset:          0x4
102# CHECK-NEXT:       - Type:            R_WASM_GLOBAL_INDEX_LEB
103# CHECK-NEXT:         Index:           3
104# CHECK-NEXT:         Offset:          0x10
105# CHECK-NEXT:       - Type:            R_WASM_MEMORY_ADDR_LEB
106# CHECK-NEXT:         Index:           5
107# CHECK-NEXT:         Offset:          0x1C
108# CHECK-NEXT:       - Type:            R_WASM_MEMORY_ADDR_REL_SLEB
109# CHECK-NEXT:         Index:           6
110# CHECK-NEXT:         Offset:          0x22
111# CHECK-NEXT:       - Type:            R_WASM_MEMORY_ADDR_LEB
112# CHECK-NEXT:         Index:           8
113# CHECK-NEXT:         Offset:          0x2C
114# CHECK-NEXT:       - Type:            R_WASM_TABLE_INDEX_REL_SLEB
115# CHECK-NEXT:         Index:           9
116# CHECK-NEXT:         Offset:          0x32
117# CHECK-NEXT:     Functions:
118# CHECK-NEXT:       - Index:           1
119# CHECK-NEXT:         Locals:          []
120# CHECK-NEXT:         Body:            2380808080002802000B
121# CHECK-NEXT:       - Index:           2
122# CHECK-NEXT:         Locals:          []
123# CHECK-NEXT:         Body:            2381808080002802000B
124# CHECK-NEXT:       - Index:           3
125# CHECK-NEXT:         Locals:          []
126# CHECK-NEXT:         Body:            2380808080004180808080006A0B
127# CHECK-NEXT:       - Index:           4
128# CHECK-NEXT:         Locals:          []
129# CHECK-NEXT:         Body:            2380808080004180808080006A0B
130# CHECK-NEXT:       - Index:           5
131# CHECK-NEXT:         Locals:          []
132# CHECK-NEXT:         Body:            41000B
133# CHECK-NEXT:   - Type:            DATA
134# CHECK-NEXT:     Segments:
135# CHECK-NEXT:       - SectionOffset:   6
136# CHECK-NEXT:         InitFlags:       0
137# CHECK-NEXT:         Offset:
138# CHECK-NEXT:           Opcode:          I32_CONST
139# CHECK-NEXT:           Value:           0
140# CHECK-NEXT:         Content:         '64'
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:            load_default_data
148# CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
149# CHECK-NEXT:         Function:        1
150# CHECK-NEXT:       - Index:           1
151# CHECK-NEXT:         Kind:            DATA
152# CHECK-NEXT:         Name:            default_data
153# CHECK-NEXT:         Flags:           [ UNDEFINED ]
154# CHECK-NEXT:       - Index:           2
155# CHECK-NEXT:         Kind:            FUNCTION
156# CHECK-NEXT:         Name:            load_default_func
157# CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
158# CHECK-NEXT:         Function:        2
159# CHECK-NEXT:       - Index:           3
160# CHECK-NEXT:         Kind:            FUNCTION
161# CHECK-NEXT:         Name:            default_func
162# CHECK-NEXT:         Flags:           [ UNDEFINED ]
163# CHECK-NEXT:         Function:        0
164# CHECK-NEXT:       - Index:           4
165# CHECK-NEXT:         Kind:            FUNCTION
166# CHECK-NEXT:         Name:            load_hidden_data
167# CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
168# CHECK-NEXT:         Function:        3
169# CHECK-NEXT:       - Index:           5
170# CHECK-NEXT:         Kind:            DATA
171# CHECK-NEXT:         Name:            __memory_base
172# CHECK-NEXT:         Flags:           [ UNDEFINED ]
173# CHECK-NEXT:       - Index:           6
174# CHECK-NEXT:         Kind:            DATA
175# CHECK-NEXT:         Name:            .L.hidden_data
176# CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
177# CHECK-NEXT:         Segment:         0
178# CHECK-NEXT:         Size:            1
179# CHECK-NEXT:       - Index:           7
180# CHECK-NEXT:         Kind:            FUNCTION
181# CHECK-NEXT:         Name:            load_hidden_func
182# CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
183# CHECK-NEXT:         Function:        4
184# CHECK-NEXT:       - Index:           8
185# CHECK-NEXT:         Kind:            DATA
186# CHECK-NEXT:         Name:            __table_base
187# CHECK-NEXT:         Flags:           [ UNDEFINED ]
188# CHECK-NEXT:       - Index:           9
189# CHECK-NEXT:         Kind:            FUNCTION
190# CHECK-NEXT:         Name:            hidden_func
191# CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
192# CHECK-NEXT:         Function:        5
193# CHECK-NEXT:     SegmentInfo:
194# CHECK-NEXT:       - Index:           0
195# CHECK-NEXT:         Name:            .rodata.hidden_data
196# CHECK-NEXT:         Alignment:       0
197# CHECK-NEXT:         Flags:           [  ]
198# CHECK-NEXT: ...
199