1 # Test that undefined weak externals (global_var) and (foo) don't cause
2 # link failures and resolve to zero.
4 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
5 # RUN: wasm-ld -strip-all %t.o -o %t.wasm
6 # RUN: obj2yaml %t.wasm | FileCheck %s
8 # Also verify test that strong references in another file do cause link
9 # failure (See https://github.com/llvm/llvm-project/issues/60806)
11 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/strong-refs.s -o %t-strong.o
12 # RUN: not wasm-ld -strip-all %t.o %t-strong.o -o %t.wasm 2>&1 | FileCheck --check-prefix=ERROR %s
13 # RUN: not wasm-ld -strip-all %t-strong.o %t.o -o %t.wasm 2>&1 | FileCheck --check-prefix=ERROR %s
15 # ERROR: undefined symbol: global_var
17 .functype foo () -> (i32)
19 .globl get_address_of_foo
21 .functype get_address_of_foo () -> (i32)
25 .globl get_address_of_global_var
26 get_address_of_global_var
:
27 .functype get_address_of_global_var () -> (i32)
33 .functype _start () -> ()
34 call get_address_of_global_var
36 call get_address_of_foo
46 # CHECK-NEXT: FileHeader:
47 # CHECK-NEXT: Version: 0x1
48 # CHECK-NEXT: Sections:
49 # CHECK-NEXT: - Type: TYPE
50 # CHECK-NEXT: Signatures:
51 # CHECK-NEXT: - Index: 0
52 # CHECK-NEXT: ParamTypes: []
53 # CHECK-NEXT: ReturnTypes:
55 # CHECK-NEXT: - Index: 1
56 # CHECK-NEXT: ParamTypes: []
57 # CHECK-NEXT: ReturnTypes: []
58 # CHECK-NEXT: - Type: FUNCTION
59 # CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 1 ]
60 # CHECK-NEXT: - Type: TABLE
62 # CHECK-NEXT: - Index: 0
63 # CHECK-NEXT: ElemType: FUNCREF
65 # CHECK-NEXT: Flags: [ HAS_MAX ]
66 # CHECK-NEXT: Minimum: 0x1
67 # CHECK-NEXT: Maximum: 0x1
68 # CHECK-NEXT: - Type: MEMORY
69 # CHECK-NEXT: Memories:
70 # CHECK-NEXT: - Minimum: 0x2
71 # CHECK-NEXT: - Type: GLOBAL
72 # CHECK-NEXT: Globals:
73 # CHECK-NEXT: - Index: 0
74 # CHECK-NEXT: Type: I32
75 # CHECK-NEXT: Mutable: true
76 # CHECK-NEXT: InitExpr:
77 # CHECK-NEXT: Opcode: I32_CONST
78 # CHECK-NEXT: Value: 66560
79 # CHECK-NEXT: - Type: EXPORT
80 # CHECK-NEXT: Exports:
81 # CHECK-NEXT: - Name: memory
82 # CHECK-NEXT: Kind: MEMORY
83 # CHECK-NEXT: Index: 0
84 # CHECK-NEXT: - Name: _start
85 # CHECK-NEXT: Kind: FUNCTION
86 # CHECK-NEXT: Index: 3
87 # CHECK-NEXT: - Type: CODE
88 # CHECK-NEXT: Functions:
89 # CHECK-NEXT: - Index: 0
91 # CHECK-NEXT: Body: 000B
92 # CHECK-NEXT: - Index: 1
94 # CHECK-NEXT: Body: 4180808080000B
95 # CHECK-NEXT: - Index: 2
97 # CHECK-NEXT: Body: 4180808080000B
98 # CHECK-NEXT: - Index: 3
100 # CHECK-NEXT: Body: 1082808080001A1081808080001A1080808080001A0B