1 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
2 # RUN: wasm-ld --no-entry %t.o -o %t.wasm
3 # RUN: obj2yaml %t.wasm | FileCheck %s
5 # This test defines a command with two exported functions, as well as a static
6 # constructor and a static destructor. Check that the exports, constructor, and
7 # destructor are all set up properly.
11 .functype foo_i32 (i32, i32) -> (i32)
19 .functype foo_f64 (f64, f64) -> (f64)
27 .functype some_ctor () -> ()
32 .functype some_dtor () -> ()
38 .functype __cxa_atexit (i32, i32, i32) -> (i32)
42 .section .text..Lcall_dtors.1,"",@
44 .functype .Lcall_dtors.1 (i32) -> ()
48 .section .text..Lregister_call_dtors.1,"",@
49 .Lregister_call_dtors.1:
50 .functype .Lregister_call_dtors.1 () -> ()
52 i32.const
.Lcall_dtors.1
63 .section .init_array.1,"",@
66 .int32 .Lregister_call_dtors.1
67 .export_name foo_i32, foo_i32
68 .export_name foo_f64, foo_f64
70 # CHECK: - Type: EXPORT
71 # CHECK-NEXT: Exports:
72 # CHECK-NEXT: - Name: memory
73 # CHECK-NEXT: Kind: MEMORY
74 # CHECK-NEXT: Index: 0
75 # CHECK-NEXT: - Name: foo_i32
76 # CHECK-NEXT: Kind: FUNCTION
77 # CHECK-NEXT: Index: 8
78 # CHECK-NEXT: - Name: foo_f64
79 # CHECK-NEXT: Kind: FUNCTION
80 # CHECK-NEXT: Index: 9
85 # CHECK-NEXT: Locals: []
86 # CHECK-NEXT: Body: 10002000200110010B
87 # CHECK-NEXT: - Index: 9
88 # CHECK-NEXT: Locals: []
89 # CHECK-NEXT: Body: 10002000200110020B
91 # CHECK: - Type: CUSTOM
92 # CHECK-NEXT: Name: name
93 # CHECK-NEXT: FunctionNames:
94 # CHECK-NEXT: - Index: 0
95 # CHECK-NEXT: Name: __wasm_call_ctors
96 # CHECK-NEXT: - Index: 1
97 # CHECK-NEXT: Name: foo_i32
98 # CHECK-NEXT: - Index: 2
99 # CHECK-NEXT: Name: foo_f64
100 # CHECK-NEXT: - Index: 3
101 # CHECK-NEXT: Name: some_ctor
102 # CHECK-NEXT: - Index: 4
103 # CHECK-NEXT: Name: some_dtor
104 # CHECK-NEXT: - Index: 5
105 # CHECK-NEXT: Name: __cxa_atexit
106 # CHECK-NEXT: - Index: 6
107 # CHECK-NEXT: Name: .Lcall_dtors.1
108 # CHECK-NEXT: - Index: 7
109 # CHECK-NEXT: Name: .Lregister_call_dtors.1
110 # CHECK-NEXT: - Index: 8
111 # CHECK-NEXT: Name: foo_i32.command_export
112 # CHECK-NEXT: - Index: 9
113 # CHECK-NEXT: Name: foo_f64.command_export