1 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2 # RUN: wasm-ld -strip-all %t.o -o %t.wasm
3 # RUN: obj2yaml %t.wasm | FileCheck %s
5 # Test that undefined weak externals (global_var) and (foo) don't cause
6 # link failures and resolve to zero.
8 .functype foo () -> (i32)
10 .globl get_address_of_foo
12 .functype get_address_of_foo () -> (i32)
16 .globl get_address_of_global_var
17 get_address_of_global_var
:
18 .functype get_address_of_global_var () -> (i32)
24 .functype _start () -> ()
25 call get_address_of_global_var
27 call get_address_of_foo
38 # CHECK-NEXT: FileHeader:
39 # CHECK-NEXT: Version: 0x1
40 # CHECK-NEXT: Sections:
41 # CHECK-NEXT: - Type: TYPE
42 # CHECK-NEXT: Signatures:
43 # CHECK-NEXT: - Index: 0
44 # CHECK-NEXT: ParamTypes: []
45 # CHECK-NEXT: ReturnTypes:
47 # CHECK-NEXT: - Index: 1
48 # CHECK-NEXT: ParamTypes: []
49 # CHECK-NEXT: ReturnTypes: []
50 # CHECK-NEXT: - Type: FUNCTION
51 # CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 1 ]
52 # CHECK-NEXT: - Type: TABLE
54 # CHECK-NEXT: - Index: 0
55 # CHECK-NEXT: ElemType: FUNCREF
57 # CHECK-NEXT: Flags: [ HAS_MAX ]
58 # CHECK-NEXT: Minimum: 0x1
59 # CHECK-NEXT: Maximum: 0x1
60 # CHECK-NEXT: - Type: MEMORY
61 # CHECK-NEXT: Memories:
62 # CHECK-NEXT: - Minimum: 0x2
63 # CHECK-NEXT: - Type: GLOBAL
64 # CHECK-NEXT: Globals:
65 # CHECK-NEXT: - Index: 0
66 # CHECK-NEXT: Type: I32
67 # CHECK-NEXT: Mutable: true
68 # CHECK-NEXT: InitExpr:
69 # CHECK-NEXT: Opcode: I32_CONST
70 # CHECK-NEXT: Value: 66560
71 # CHECK-NEXT: - Type: EXPORT
72 # CHECK-NEXT: Exports:
73 # CHECK-NEXT: - Name: memory
74 # CHECK-NEXT: Kind: MEMORY
75 # CHECK-NEXT: Index: 0
76 # CHECK-NEXT: - Name: _start
77 # CHECK-NEXT: Kind: FUNCTION
78 # CHECK-NEXT: Index: 3
79 # CHECK-NEXT: - Type: CODE
80 # CHECK-NEXT: Functions:
81 # CHECK-NEXT: - Index: 0
83 # CHECK-NEXT: Body: 000B
84 # CHECK-NEXT: - Index: 1
86 # CHECK-NEXT: Body: 4180808080000B
87 # CHECK-NEXT: - Index: 2
89 # CHECK-NEXT: Body: 4180808080000B
90 # CHECK-NEXT: - Index: 3
92 # CHECK-NEXT: Body: 1082808080001A1081808080001A1080808080001A0B