llvm-project
84 строки · 2.7 Кб
1# Unresolve data symbols are allowing under import-dynamic when GOT
2# relocations are used
3# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t-dynamic.o
4# RUN: wasm-ld %t-dynamic.o -o %t.wasm --unresolved-symbols=import-dynamic 2>&1 | FileCheck -check-prefix=WARN %s
5# WARN: wasm-ld: warning: dynamic imports are not yet stable (--unresolved-symbols=import-dynamic)
6# RUN: obj2yaml %t.wasm | FileCheck %s
7
8.functype undef () -> ()
9
10.globl get_data_addr
11get_data_addr:
12.functype get_data_addr () -> (i32)
13global.get undef_data@GOT
14return
15end_function
16
17.globl get_func_addr
18get_func_addr:
19.functype get_func_addr () -> (i32)
20global.get undef@GOT
21return
22end_function
23
24.globl _start
25_start:
26.functype _start () -> ()
27call undef
28call get_func_addr
29drop
30call get_data_addr
31i32.load data_ptr
32drop
33end_function
34
35.section .data.data_ptr,"",@
36data_ptr:
37.int32 data_external+42
38.size data_ptr, 4
39
40.size data_external, 4
41
42# CHECK: - Type: IMPORT
43# CHECK-NEXT: Imports:
44# CHECK-NEXT: - Module: env
45# CHECK-NEXT: Field: undef
46# CHECK-NEXT: Kind: FUNCTION
47# CHECK-NEXT: SigIndex: 0
48# CHECK-NEXT: - Module: GOT.mem
49# CHECK-NEXT: Field: undef_data
50# CHECK-NEXT: Kind: GLOBAL
51# CHECK-NEXT: GlobalType: I32
52# CHECK-NEXT: GlobalMutable: true
53# CHECK-NEXT: - Module: GOT.func
54# CHECK-NEXT: Field: undef
55# CHECK-NEXT: Kind: GLOBAL
56# CHECK-NEXT: GlobalType: I32
57# CHECK-NEXT: GlobalMutable: true
58
59# CHECK: - Type: CUSTOM
60# CHECK-NEXT: Name: name
61# CHECK-NEXT: FunctionNames:
62# CHECK-NEXT: - Index: 0
63# CHECK-NEXT: Name: undef
64# CHECK-NEXT: - Index: 1
65# CHECK-NEXT: Name: __wasm_apply_data_relocs
66# CHECK-NEXT: - Index: 2
67# CHECK-NEXT: Name: get_data_addr
68# CHECK-NEXT: - Index: 3
69# CHECK-NEXT: Name: get_func_addr
70# CHECK-NEXT: - Index: 4
71# CHECK-NEXT: Name: _start
72# CHECK-NEXT: GlobalNames:
73# CHECK-NEXT: - Index: 0
74# CHECK-NEXT: Name: undef_data
75# CHECK-NEXT: - Index: 1
76# CHECK-NEXT: Name: undef
77# CHECK-NEXT: - Index: 2
78# CHECK-NEXT: Name: data_external
79# CHECK-NEXT: - Index: 3
80# CHECK-NEXT: Name: __stack_pointer
81# CHECK-NEXT: DataSegmentNames:
82# CHECK-NEXT: - Index: 0
83# CHECK-NEXT: Name: .data
84# CHECK-NEXT:...
85