1# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/weak-symbol1.s -o %t1.o
2# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/weak-symbol2.s -o %t2.o
3# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
4# RUN: wasm-ld --export-dynamic -o %t.wasm %t.o %t1.o %t2.o
5# RUN: obj2yaml %t.wasm | FileCheck %s
6
7.globl  _start
8_start:
9  .functype _start () -> ()
10  call  weakFn
11  drop
12  end_function
13
14.functype weakFn () -> (i32)
15.size weakGlobal, 4
16
17# CHECK:      --- !WASM
18# CHECK-NEXT: FileHeader:
19# CHECK-NEXT:   Version:         0x1
20# CHECK-NEXT: Sections:
21# CHECK-NEXT:   - Type:            TYPE
22# CHECK-NEXT:     Signatures:
23# CHECK-NEXT:       - Index:           0
24# CHECK-NEXT:         ParamTypes:      []
25# CHECK-NEXT:         ReturnTypes:     []
26# CHECK-NEXT:       - Index:           1
27# CHECK-NEXT:         ParamTypes:      []
28# CHECK-NEXT:         ReturnTypes:
29# CHECK-NEXT:           - I32
30# CHECK-NEXT:   - Type:            FUNCTION
31# CHECK-NEXT:     FunctionTypes:   [ 0, 1, 1, 1 ]
32# CHECK-NEXT:   - Type:            TABLE
33# CHECK-NEXT:     Tables:
34# CHECK-NEXT:       - Index:           0
35# CHECK-NEXT:         ElemType:        FUNCREF
36# CHECK-NEXT:         Limits:
37# CHECK-NEXT:           Flags:           [ HAS_MAX ]
38# CHECK-NEXT:           Initial:         0x2
39# CHECK-NEXT:           Maximum:         0x2
40# CHECK-NEXT:   - Type:            MEMORY
41# CHECK-NEXT:     Memories:
42# CHECK-NEXT:       - Initial:         0x2
43# CHECK-NEXT:   - Type:            GLOBAL
44# CHECK-NEXT:     Globals:
45# CHECK-NEXT:       - Index:           0
46# CHECK-NEXT:         Type:            I32
47# CHECK-NEXT:         Mutable:         true
48# CHECK-NEXT:         InitExpr:
49# CHECK-NEXT:           Opcode:          I32_CONST
50# CHECK-NEXT:           Value:           66576
51# CHECK-NEXT:       - Index:           1
52# CHECK-NEXT:         Type:            I32
53# CHECK-NEXT:         Mutable:         false
54# CHECK-NEXT:         InitExpr:
55# CHECK-NEXT:           Opcode:          I32_CONST
56# CHECK-NEXT:           Value:           1024
57# CHECK-NEXT:   - Type:            EXPORT
58# CHECK-NEXT:     Exports:
59# CHECK-NEXT:       - Name:            memory
60# CHECK-NEXT:         Kind:            MEMORY
61# CHECK-NEXT:         Index:           0
62# CHECK-NEXT:       - Name:            _start
63# CHECK-NEXT:         Kind:            FUNCTION
64# CHECK-NEXT:         Index:           0
65# CHECK-NEXT:       - Name:            weakFn
66# CHECK-NEXT:         Kind:            FUNCTION
67# CHECK-NEXT:         Index:           1
68# CHECK-NEXT:       - Name:            exportWeak1
69# CHECK-NEXT:         Kind:            FUNCTION
70# CHECK-NEXT:         Index:           2
71# CHECK-NEXT:       - Name:            weakGlobal
72# CHECK-NEXT:         Kind:            GLOBAL
73# CHECK-NEXT:         Index:           1
74# CHECK-NEXT:       - Name:            exportWeak2
75# CHECK-NEXT:         Kind:            FUNCTION
76# CHECK-NEXT:         Index:           3
77# CHECK-NEXT:   - Type:            ELEM
78# CHECK-NEXT:     Segments:
79# CHECK-NEXT:       - Offset:
80# CHECK-NEXT:           Opcode:          I32_CONST
81# CHECK-NEXT:           Value:           1
82# CHECK-NEXT:         Functions:       [ 1 ]
83# CHECK-NEXT:   - Type:            CODE
84# CHECK-NEXT:     Functions:
85# CHECK-NEXT:       - Index:           0
86# CHECK-NEXT:         Locals:
87# CHECK-NEXT:         Body:            1081808080001A0B
88# CHECK-NEXT:       - Index:           1
89# CHECK-NEXT:         Locals:
90# CHECK-NEXT:         Body:            41010B
91# CHECK-NEXT:       - Index:           2
92# CHECK-NEXT:         Locals:
93# CHECK-NEXT:         Body:            4181808080000B
94# CHECK-NEXT:       - Index:           3
95# CHECK-NEXT:         Locals:
96# CHECK-NEXT:         Body:            4181808080000B
97# CHECK-NEXT:   - Type:            DATA
98# CHECK-NEXT:     Segments:
99# CHECK-NEXT:       - SectionOffset:   7
100# CHECK-NEXT:         InitFlags:       0
101# CHECK-NEXT:         Offset:
102# CHECK-NEXT:           Opcode:          I32_CONST
103# CHECK-NEXT:           Value:           1024
104# CHECK-NEXT:         Content:         '01000000'
105# CHECK-NEXT:   - Type:            CUSTOM
106# CHECK-NEXT:     Name:            name
107# CHECK-NEXT:     FunctionNames:
108# CHECK-NEXT:       - Index:           0
109# CHECK-NEXT:         Name:            _start
110# CHECK-NEXT:       - Index:           1
111# CHECK-NEXT:         Name:            weakFn
112# CHECK-NEXT:       - Index:           2
113# CHECK-NEXT:         Name:            exportWeak1
114# CHECK-NEXT:       - Index:           3
115# CHECK-NEXT:         Name:            exportWeak2
116# CHECK-NEXT:     GlobalNames:
117# CHECK-NEXT:       - Index:           0
118# CHECK-NEXT:         Name:            __stack_pointer
119# CHECK-NEXT: ...
120