Index: test/wasm/init-fini.ll =================================================================== --- test/wasm/init-fini.ll +++ test/wasm/init-fini.ll @@ -23,8 +23,8 @@ ret void } -define void @__cxa_atexit() { - ret void +define i32 @__cxa_atexit(i32 %func, i32 %arg, i32 %dso_handle) { + ret i32 0 } define hidden void @_start() { @@ -52,9 +52,9 @@ ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 6, 9, 13, 15, 17 ] +; CHECK-NEXT: Functions: [ 6, 8, 12, 14, 16 ] -; CHECK: Body: 100010011007100B100E100B10101000100A100B10120B +; CHECK: Body: 100010011007100A100D100A100F10001009100A10110B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: linking ; CHECK-NEXT: DataSize: 0 @@ -78,28 +78,26 @@ ; CHECK-NEXT: - Index: 7 ; CHECK-NEXT: Name: .Lregister_call_dtors.101 ; CHECK-NEXT: - Index: 8 -; CHECK-NEXT: Name: .Lbitcast -; CHECK-NEXT: - Index: 9 ; CHECK-NEXT: Name: .Lcall_dtors.1001 -; CHECK-NEXT: - Index: 10 +; CHECK-NEXT: - Index: 9 ; CHECK-NEXT: Name: .Lregister_call_dtors.1001 -; CHECK-NEXT: - Index: 11 +; CHECK-NEXT: - Index: 10 ; CHECK-NEXT: Name: myctor -; CHECK-NEXT: - Index: 12 +; CHECK-NEXT: - Index: 11 ; CHECK-NEXT: Name: mydtor -; CHECK-NEXT: - Index: 13 +; CHECK-NEXT: - Index: 12 ; CHECK-NEXT: Name: .Lcall_dtors.101 -; CHECK-NEXT: - Index: 14 +; CHECK-NEXT: - Index: 13 ; CHECK-NEXT: Name: .Lregister_call_dtors.101 -; CHECK-NEXT: - Index: 15 +; CHECK-NEXT: - Index: 14 ; CHECK-NEXT: Name: .Lcall_dtors.202 -; CHECK-NEXT: - Index: 16 +; CHECK-NEXT: - Index: 15 ; CHECK-NEXT: Name: .Lregister_call_dtors.202 -; CHECK-NEXT: - Index: 17 +; CHECK-NEXT: - Index: 16 ; CHECK-NEXT: Name: .Lcall_dtors.2002 -; CHECK-NEXT: - Index: 18 +; CHECK-NEXT: - Index: 17 ; CHECK-NEXT: Name: .Lregister_call_dtors.2002 -; CHECK-NEXT: - Index: 19 +; CHECK-NEXT: - Index: 18 ; CHECK-NEXT: Name: __wasm_call_ctors ; CHECK-NEXT: ... @@ -126,8 +124,6 @@ ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] ; RELOC-NEXT: - Name: .Lregister_call_dtors.101 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: - Name: .Lbitcast -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] ; RELOC-NEXT: - Name: .Lcall_dtors.1001 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] ; RELOC-NEXT: - Name: .Lregister_call_dtors.1001 @@ -156,21 +152,21 @@ ; RELOC-NEXT: - Priority: 101 ; RELOC-NEXT: FunctionIndex: 7 ; RELOC-NEXT: - Priority: 101 -; RELOC-NEXT: FunctionIndex: 11 +; RELOC-NEXT: FunctionIndex: 10 ; RELOC-NEXT: - Priority: 101 -; RELOC-NEXT: FunctionIndex: 14 +; RELOC-NEXT: FunctionIndex: 13 ; RELOC-NEXT: - Priority: 202 -; RELOC-NEXT: FunctionIndex: 11 +; RELOC-NEXT: FunctionIndex: 10 ; RELOC-NEXT: - Priority: 202 -; RELOC-NEXT: FunctionIndex: 16 +; RELOC-NEXT: FunctionIndex: 15 ; RELOC-NEXT: - Priority: 1001 ; RELOC-NEXT: FunctionIndex: 0 ; RELOC-NEXT: - Priority: 1001 -; RELOC-NEXT: FunctionIndex: 10 +; RELOC-NEXT: FunctionIndex: 9 ; RELOC-NEXT: - Priority: 2002 -; RELOC-NEXT: FunctionIndex: 11 +; RELOC-NEXT: FunctionIndex: 10 ; RELOC-NEXT: - Priority: 2002 -; RELOC-NEXT: FunctionIndex: 18 +; RELOC-NEXT: FunctionIndex: 17 ; RELOC-NEXT: - Type: CUSTOM ; RELOC-NEXT: Name: name ; RELOC-NEXT: FunctionNames: @@ -191,25 +187,23 @@ ; RELOC-NEXT: - Index: 7 ; RELOC-NEXT: Name: .Lregister_call_dtors.101 ; RELOC-NEXT: - Index: 8 -; RELOC-NEXT: Name: .Lbitcast -; RELOC-NEXT: - Index: 9 ; RELOC-NEXT: Name: .Lcall_dtors.1001 -; RELOC-NEXT: - Index: 10 +; RELOC-NEXT: - Index: 9 ; RELOC-NEXT: Name: .Lregister_call_dtors.1001 -; RELOC-NEXT: - Index: 11 +; RELOC-NEXT: - Index: 10 ; RELOC-NEXT: Name: myctor -; RELOC-NEXT: - Index: 12 +; RELOC-NEXT: - Index: 11 ; RELOC-NEXT: Name: mydtor -; RELOC-NEXT: - Index: 13 +; RELOC-NEXT: - Index: 12 ; RELOC-NEXT: Name: .Lcall_dtors.101 -; RELOC-NEXT: - Index: 14 +; RELOC-NEXT: - Index: 13 ; RELOC-NEXT: Name: .Lregister_call_dtors.101 -; RELOC-NEXT: - Index: 15 +; RELOC-NEXT: - Index: 14 ; RELOC-NEXT: Name: .Lcall_dtors.202 -; RELOC-NEXT: - Index: 16 +; RELOC-NEXT: - Index: 15 ; RELOC-NEXT: Name: .Lregister_call_dtors.202 -; RELOC-NEXT: - Index: 17 +; RELOC-NEXT: - Index: 16 ; RELOC-NEXT: Name: .Lcall_dtors.2002 -; RELOC-NEXT: - Index: 18 +; RELOC-NEXT: - Index: 17 ; RELOC-NEXT: Name: .Lregister_call_dtors.2002 ; RELOC-NEXT: ... Index: test/wasm/signature-mismatch.ll =================================================================== --- test/wasm/signature-mismatch.ll +++ test/wasm/signature-mismatch.ll @@ -1,6 +1,10 @@ ; RUN: llc -filetype=obj %p/Inputs/ret32.ll -o %t.ret32.o ; RUN: llc -filetype=obj %s -o %t.main.o ; RUN: not lld -flavor wasm --check-signatures -o %t.wasm %t.main.o %t.ret32.o 2>&1 | FileCheck %s +; Run the test again by with the object files in the other order to verify +; the check works when the undefined symbol is resolved by an existing defined +; one. +; RUN: not lld -flavor wasm --check-signatures -o %t.wasm %t.ret32.o %t.main.o 2>&1 | FileCheck %s -check-prefix=REVERSE target triple = "wasm32-unknown-unknown-wasm" @@ -16,3 +20,7 @@ ; CHECK: error: function signature mismatch: ret32 ; CHECK-NEXT: >>> defined as (I32, I64, I32) -> I32 in {{.*}}.main.o ; CHECK-NEXT: >>> defined as (F32) -> I32 in {{.*}}.ret32.o + +; REVERSE: error: function signature mismatch: ret32 +; REVERSE-NEXT: >>> defined as (F32) -> I32 in {{.*}}.ret32.o +; REVERSE-NEXT: >>> defined as (I32, I64, I32) -> I32 in {{.*}}.main.o Index: wasm/Symbols.h =================================================================== --- wasm/Symbols.h +++ wasm/Symbols.h @@ -94,7 +94,7 @@ S->kind() == UndefinedFunctionKind; } - bool hasFunctionType() const { return FunctionType != nullptr; } + bool hasFunctionType() const { return Chunk || FunctionType; } const WasmSignature &getFunctionType() const; uint32_t getTableIndex() const;