114 lines · plain
1# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s2# RUN: wasm-ld --no-entry %t.o -o %t.wasm3# RUN: obj2yaml %t.wasm | FileCheck %s4 5# This test defines a command with two exported functions, as well as a static6# constructor and a static destructor. Check that the exports, constructor, and7# destructor are all set up properly.8 9 .globl foo_i3210foo_i32:11 .functype foo_i32 (i32, i32) -> (i32)12 local.get 013 local.get 114 i32.add15 end_function16 17 .globl foo_f6418foo_f64:19 .functype foo_f64 (f64, f64) -> (f64)20 local.get 021 local.get 122 f64.add23 end_function24 25 .globl some_ctor26some_ctor:27 .functype some_ctor () -> ()28 end_function29 30 .globl some_dtor31some_dtor:32 .functype some_dtor () -> ()33 end_function34 35 .hidden __cxa_atexit36 .globl __cxa_atexit37__cxa_atexit:38 .functype __cxa_atexit (i32, i32, i32) -> (i32)39 i32.const 040 end_function41 42 .section .text..Lcall_dtors.1,"",@43.Lcall_dtors.1:44 .functype .Lcall_dtors.1 (i32) -> ()45 call some_dtor46 end_function47 48 .section .text..Lregister_call_dtors.1,"",@49.Lregister_call_dtors.1:50 .functype .Lregister_call_dtors.1 () -> ()51 block52 i32.const .Lcall_dtors.153 i32.const 054 i32.const 055 call __cxa_atexit56 i32.eqz57 br_if 058 unreachable59.LBB6_2:60 end_block61 end_function62 63 .section .init_array.1,"",@64 .p2align 265 .int32 some_ctor66 .int32 .Lregister_call_dtors.167 .export_name foo_i32, foo_i3268 .export_name foo_f64, foo_f6469 70# CHECK: - Type: EXPORT71# CHECK-NEXT: Exports:72# CHECK-NEXT: - Name: memory73# CHECK-NEXT: Kind: MEMORY74# CHECK-NEXT: Index: 075# CHECK-NEXT: - Name: foo_i3276# CHECK-NEXT: Kind: FUNCTION77# CHECK-NEXT: Index: 878# CHECK-NEXT: - Name: foo_f6479# CHECK-NEXT: Kind: FUNCTION80# CHECK-NEXT: Index: 981 82# CHECK: - Type: CODE83 84# CHECK: - Index: 885# CHECK-NEXT: Locals: []86# CHECK-NEXT: Body: 10002000200110010B87# CHECK-NEXT: - Index: 988# CHECK-NEXT: Locals: []89# CHECK-NEXT: Body: 10002000200110020B90 91# CHECK: - Type: CUSTOM92# CHECK-NEXT: Name: name93# CHECK-NEXT: FunctionNames:94# CHECK-NEXT: - Index: 095# CHECK-NEXT: Name: __wasm_call_ctors96# CHECK-NEXT: - Index: 197# CHECK-NEXT: Name: foo_i3298# CHECK-NEXT: - Index: 299# CHECK-NEXT: Name: foo_f64100# CHECK-NEXT: - Index: 3101# CHECK-NEXT: Name: some_ctor102# CHECK-NEXT: - Index: 4103# CHECK-NEXT: Name: some_dtor104# CHECK-NEXT: - Index: 5105# CHECK-NEXT: Name: __cxa_atexit106# CHECK-NEXT: - Index: 6107# CHECK-NEXT: Name: .Lcall_dtors.1108# CHECK-NEXT: - Index: 7109# CHECK-NEXT: Name: .Lregister_call_dtors.1110# CHECK-NEXT: - Index: 8111# CHECK-NEXT: Name: foo_i32.command_export112# CHECK-NEXT: - Index: 9113# CHECK-NEXT: Name: foo_f64.command_export114