86 lines · plain
1; RUN: llc -filetype=obj -o %t.o %s2; RUN: wasm-ld %t.o -o %t.wasm3; RUN: obj2yaml %t.wasm | FileCheck %s4 5; RUN: wasm-ld --export=__wasm_call_ctors %t.o -o %t.export.wasm6; RUN: obj2yaml %t.export.wasm | FileCheck %s -check-prefix=EXPORT7 8; Test that we emit wrappers and call __wasm_call_ctor when not referenced.9 10target triple = "wasm32-unknown-unknown"11 12define hidden void @_start() {13entry:14 ret void15}16 17define hidden void @func1() {18entry:19 ret void20}21 22define hidden void @func2() {23entry:24 ret void25}26 27define hidden i32 @__cxa_atexit(i32 %func, i32 %arg, i32 %dso_handle) {28 ret i32 %func29}30 31@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [32 { i32, ptr, ptr } { i32 1, ptr @func1, ptr null }33]34 35@llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [36 { i32, ptr, ptr } { i32 1, ptr @func2, ptr null }37]38 39; Check that we have exactly the needed exports: `memory` because that's40; currently on by default, and `_start`, because that's the default entrypoint.41 42; CHECK: - Type: EXPORT43; CHECK-NEXT: Exports:44; CHECK-NEXT: - Name: memory45; CHECK-NEXT: Kind: MEMORY46; CHECK-NEXT: Index: 047; CHECK-NEXT: - Name: _start48; CHECK-NEXT: Kind: FUNCTION49; CHECK-NEXT: Index: 750 51; Check the body of `_start`'s command-export wrapper.52 53; CHECK: - Type: CODE54 55; CHECK: - Index: 756; CHECK-NEXT: Locals: []57; CHECK-NEXT: Body: 100010010B58 59; Check the symbol table to ensure all the functions are here, and that60; index 7 above refers to the function we think it does.61 62; CHECK: - Type: CUSTOM63; CHECK-NEXT: Name: name64; CHECK-NEXT: FunctionNames:65; CHECK-NEXT: - Index: 066; CHECK-NEXT: Name: __wasm_call_ctors67; CHECK-NEXT: - Index: 168; CHECK-NEXT: Name: _start69; CHECK-NEXT: - Index: 270; CHECK-NEXT: Name: func171; CHECK-NEXT: - Index: 372; CHECK-NEXT: Name: func273; CHECK-NEXT: - Index: 474; CHECK-NEXT: Name: __cxa_atexit75; CHECK-NEXT: - Index: 576; CHECK-NEXT: Name: .Lcall_dtors.177; CHECK-NEXT: - Index: 678; CHECK-NEXT: Name: .Lregister_call_dtors.179; CHECK-NEXT: - Index: 780; CHECK-NEXT: Name: _start.command_export81 82; EXPORT: __wasm_call_ctors83; EXPORT: func184; EXPORT: func285; EXPORT: __cxa_atexit86