Skip to content

Commit 7cdff15

Browse files
committed
add a test
1 parent 3f65a78 commit 7cdff15

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

lld/test/wasm/pie.s

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-emscripten %S/Inputs/internal_func.s -o %t.internal_func.o
33
# RUN: wasm-ld --no-gc-sections --experimental-pic -pie --unresolved-symbols=import-dynamic -o %t.wasm %t.o %t.internal_func.o
44
# RUN: obj2yaml %t.wasm | FileCheck %s
5-
# RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_apply_data_relocs --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DISASSEM
5+
# RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_apply_data_relocs,__wasm_apply_global_relocs --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DISASSEM
66

77
.functype external_func () -> ()
88
.functype internal_func1 () -> (i32)
@@ -41,6 +41,11 @@ foo:
4141
drop
4242

4343
global.get __stack_pointer
44+
i32.load 0
45+
call_indirect () -> (i32)
46+
drop
47+
48+
global.get __wasm_first_page_end@GOT
4449
end_function
4550

4651
get_data_address:
@@ -145,6 +150,18 @@ _start:
145150
# DISASSEM-LABEL: <__wasm_apply_data_relocs>:
146151
# DISASSEM: end
147152

153+
# global 6 is __wasm_first_page_end, which is ABSOLUTE and
154+
# thus should not be relocated.
155+
#
156+
# DISASSEM-LABEL: <__wasm_apply_global_relocs>:
157+
# DISASSEM: global.set 4
158+
# DISASSEM: global.set 5
159+
# DISASSEM-NOT: global.set 6
160+
# DISASSEM: global.set 7
161+
# DISASSEM: global.set 8
162+
# DISASSEM: global.set 9
163+
# DISASSEM: end
164+
148165
# Run the same test with extended-const support. When this is available
149166
# we don't need __wasm_apply_global_relocs and instead rely on the add
150167
# instruction in the InitExpr. We also, therefore, do not need these globals
@@ -173,17 +190,23 @@ _start:
173190
# EXTENDED-CONST-NEXT: Type: I32
174191
# EXTENDED-CONST-NEXT: Mutable: false
175192
# EXTENDED-CONST-NEXT: InitExpr:
193+
# EXTENDED-CONST-NEXT: Opcode: I32_CONST
194+
# EXTENDED-CONST-NEXT: Value: 65536
195+
# EXTENDED-CONST-NEXT: - Index: 7
196+
# EXTENDED-CONST-NEXT: Type: I32
197+
# EXTENDED-CONST-NEXT: Mutable: false
198+
# EXTENDED-CONST-NEXT: InitExpr:
176199
# EXTENDED-CONST-NEXT: Extended: true
177200
# This instruction sequence decodes to:
178201
# (global.get[0x23] 0x1 i32.const[0x41] 0x0C i32.add[0x6A] end[0x0b])
179202
# EXTENDED-CONST-NEXT: Body: 2301410C6A0B
180-
# EXTENDED-CONST-NEXT: - Index: 7
203+
# EXTENDED-CONST-NEXT: - Index: 8
181204
# EXTENDED-CONST-NEXT: Type: I32
182205
# EXTENDED-CONST-NEXT: Mutable: false
183206
# EXTENDED-CONST-NEXT: InitExpr:
184207
# EXTENDED-CONST-NEXT: Opcode: GLOBAL_GET
185208
# EXTENDED-CONST-NEXT: Index: 2
186-
# EXTENDED-CONST-NEXT: - Index: 8
209+
# EXTENDED-CONST-NEXT: - Index: 9
187210
# EXTENDED-CONST-NEXT: Type: I32
188211
# EXTENDED-CONST-NEXT: Mutable: false
189212
# EXTENDED-CONST-NEXT: InitExpr:

0 commit comments

Comments
 (0)