1 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2 # RUN: wasm-ld --experimental-pic -shared -o %t.wasm %t.o
3 # RUN: obj2yaml %t.wasm | FileCheck %s
4 # RUN: llvm-objdump -d %t.wasm | FileCheck %s -check-prefix=ASM
6 # Verify the weakly defined fuctions (weak_func) are both imported and exported,
7 # and that internal usage (direct call) always uses the imported version.
8 # Hidden functions, even if weak, should not be imported or exported.
13 .functype weak_func () -> (i32)
17 .globl hidden_weak_func
18 .hidden hidden_weak_func
19 .weak hidden_weak_func
21 .functype hidden_weak_func () -> (i32)
28 .functype call_weak () -> (i32)
30 # ASM: 10 80 80 80 80 00 call 0
33 # ASM: 10 83 80 80 80 00 call 3
37 # CHECK: - Type: IMPORT
38 # CHECK-NEXT: Imports:
39 # CHECK-NEXT: - Module: env
40 # CHECK-NEXT: Field: memory
41 # CHECK-NEXT: Kind: MEMORY
43 # CHECK-NEXT: Minimum: 0x0
44 # CHECK-NEXT: - Module: env
45 # CHECK-NEXT: Field: __memory_base
46 # CHECK-NEXT: Kind: GLOBAL
47 # CHECK-NEXT: GlobalType: I32
48 # CHECK-NEXT: GlobalMutable: false
49 # CHECK-NEXT: - Module: env
50 # CHECK-NEXT: Field: __table_base
51 # CHECK-NEXT: Kind: GLOBAL
52 # CHECK-NEXT: GlobalType: I32
53 # CHECK-NEXT: GlobalMutable: false
54 # CHECK-NEXT: - Module: env
55 # CHECK-NEXT: Field: weak_func
56 # CHECK-NEXT: Kind: FUNCTION
57 # CHECK-NEXT: SigIndex: 0
58 # CHECK-NEXT: - Type: FUNCTION
60 # CHECK: - Type: EXPORT
61 # CHECK-NEXT: Exports:
62 # CHECK-NEXT: - Name: __wasm_call_ctors
63 # CHECK-NEXT: Kind: FUNCTION
64 # CHECK-NEXT: Index: 1
65 # CHECK-NEXT: - Name: weak_func
66 # CHECK-NEXT: Kind: FUNCTION
67 # CHECK-NEXT: Index: 2
68 # CHECK-NEXT: - Name: call_weak
69 # CHECK-NEXT: Kind: FUNCTION
70 # CHECK-NEXT: Index: 4
71 # CHECK-NEXT: - Type: CODE
73 # CHECK: - Type: CUSTOM
74 # CHECK-NEXT: Name: name
75 # CHECK-NEXT: FunctionNames:
76 # CHECK-NEXT: - Index: 0
77 # CHECK-NEXT: Name: weak_func
78 # CHECK-NEXT: - Index: 1
79 # CHECK-NEXT: Name: __wasm_call_ctors
80 # CHECK-NEXT: - Index: 2
81 # CHECK-NEXT: Name: weak_func
82 # CHECK-NEXT: - Index: 3
83 # CHECK-NEXT: Name: hidden_weak_func
84 # CHECK-NEXT: - Index: 4
85 # CHECK-NEXT: Name: call_weak