diff --git a/lld/test/wasm/alias.ll b/lld/test/wasm/alias.ll --- a/lld/test/wasm/alias.ll +++ b/lld/test/wasm/alias.ll @@ -22,7 +22,7 @@ ; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0 ] +; CHECK-NEXT: FunctionTypes: [ 0 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: FUNCREF @@ -66,23 +66,18 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: start_alias ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 0B -; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start ; CHECK-NEXT: ... diff --git a/lld/test/wasm/archive-export.ll b/lld/test/wasm/archive-export.ll --- a/lld/test/wasm/archive-export.ll +++ b/lld/test/wasm/archive-export.ll @@ -22,16 +22,16 @@ CHECK-NEXT: Index: 2 CHECK-NEXT: - Name: foo CHECK-NEXT: Kind: FUNCTION -CHECK-NEXT: Index: 2 +CHECK-NEXT: Index: 1 CHECK-NEXT: - Name: bar CHECK-NEXT: Kind: FUNCTION -CHECK-NEXT: Index: 3 +CHECK-NEXT: Index: 2 CHECK-NEXT: - Name: archive2_symbol CHECK-NEXT: Kind: FUNCTION -CHECK-NEXT: Index: 4 +CHECK-NEXT: Index: 3 CHECK-NEXT: - Name: _start CHECK-NEXT: Kind: FUNCTION -CHECK-NEXT: Index: 1 +CHECK-NEXT: Index: 0 CHECK-NEXT: - Type: CODE NOEXPORT: Exports: @@ -46,5 +46,5 @@ NOEXPORT-NEXT: Index: 2 NOEXPORT-NEXT: - Name: _start NOEXPORT-NEXT: Kind: FUNCTION -NOEXPORT-NEXT: Index: 1 +NOEXPORT-NEXT: Index: 0 NOEXPORT-NEXT: - Type: CODE diff --git a/lld/test/wasm/call-indirect.ll b/lld/test/wasm/call-indirect.ll --- a/lld/test/wasm/call-indirect.ll +++ b/lld/test/wasm/call-indirect.ll @@ -57,7 +57,7 @@ ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - I32 ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 3, 0, 3, 1, 3, 4 ] +; CHECK-NEXT: FunctionTypes: [ 0, 3, 1, 3, 4 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: FUNCREF @@ -107,48 +107,45 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: bar ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: call_bar_indirect ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: foo ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: indirect_func ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: call_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 5 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 1, 3 ] +; CHECK-NEXT: Functions: [ 0, 2 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B -; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 42010B -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: ; CHECK-NEXT: - Type: I32 ; CHECK-NEXT: Count: 1 ; CHECK-NEXT: Body: 4100280284888080002100410028028088808000118080808000001A2000118180808000001A0B -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 41020B -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 410028028888808000118180808000001A0B -; CHECK-NEXT: - Index: 5 +; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 42012000118280808000001A0B ; CHECK-NEXT: - Type: DATA @@ -163,15 +160,13 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: bar -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: call_bar_indirect -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: foo -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 5 +; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Name: call_ptr ; CHECK-NEXT: ... diff --git a/lld/test/wasm/comdats.ll b/lld/test/wasm/comdats.ll --- a/lld/test/wasm/comdats.ll +++ b/lld/test/wasm/comdats.ll @@ -53,40 +53,37 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: inlineFn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: constantData ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: callInline1 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: callInline2 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 2 ] +; CHECK-NEXT: Functions: [ 1 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 1081808080001A0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1082808080001A0B -; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4180888080000B -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4181808080000B -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4181808080000B ; CHECK-NEXT: - Type: DATA diff --git a/lld/test/wasm/cxx-mangling.ll b/lld/test/wasm/cxx-mangling.ll --- a/lld/test/wasm/cxx-mangling.ll +++ b/lld/test/wasm/cxx-mangling.ll @@ -34,35 +34,30 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _Z3fooi ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B -; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 000B -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 0B -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 410110828080800041011081808080000B +; CHECK-NEXT: Body: 410110818080800041011080808080000B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; DEMANGLE-NEXT: Name: 'undefined:bar(int)' ; MANGLE-NEXT: Name: 'undefined:_Z3bari' -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; DEMANGLE-NEXT: Name: 'foo(int)' ; MANGLE-NEXT: Name: _Z3fooi -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: _start ; CHECK-NEXT: ... diff --git a/lld/test/wasm/entry.ll b/lld/test/wasm/entry.ll --- a/lld/test/wasm/entry.ll +++ b/lld/test/wasm/entry.ll @@ -25,7 +25,7 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: entry ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Type: ; The __wasm_call_ctors is somewhat special since its created by the linker. diff --git a/lld/test/wasm/export.ll b/lld/test/wasm/export.ll --- a/lld/test/wasm/export.ll +++ b/lld/test/wasm/export.ll @@ -48,11 +48,11 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: hidden_function ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: used_function ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Type: CODE diff --git a/lld/test/wasm/function-imports-first.ll b/lld/test/wasm/function-imports-first.ll --- a/lld/test/wasm/function-imports-first.ll +++ b/lld/test/wasm/function-imports-first.ll @@ -24,25 +24,20 @@ ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - F32 ; CHECK: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1 ] ; CHECK: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 43000000001081808080001A0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 43000000001082808080001A0B -; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 41000B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: ret32 ; CHECK-NEXT: ... diff --git a/lld/test/wasm/function-imports.ll b/lld/test/wasm/function-imports.ll --- a/lld/test/wasm/function-imports.ll +++ b/lld/test/wasm/function-imports.ll @@ -18,25 +18,22 @@ ; CHECK: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: NORESULT -; CHECK-NEXT: ParamTypes: -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - F32 +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 0 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1 ] ; CHECK: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK: - Index: 0 ; CHECK: - Index: 1 -; CHECK: - Index: 2 ; CHECK: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: ret32 -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start ; CHECK-NEXT: ... diff --git a/lld/test/wasm/gc-imports.ll b/lld/test/wasm/gc-imports.ll --- a/lld/test/wasm/gc-imports.ll +++ b/lld/test/wasm/gc-imports.ll @@ -43,10 +43,8 @@ ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: used_undef_function ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: use_undef_global ; CHECK-NEXT: ... diff --git a/lld/test/wasm/gc-sections.ll b/lld/test/wasm/gc-sections.ll --- a/lld/test/wasm/gc-sections.ll +++ b/lld/test/wasm/gc-sections.ll @@ -38,10 +38,10 @@ ; CHECK: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: ReturnType: I64 @@ -75,12 +75,10 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: used_function -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: use_global ; CHECK-NEXT: ... diff --git a/lld/test/wasm/init-fini.ll b/lld/test/wasm/init-fini.ll --- a/lld/test/wasm/init-fini.ll +++ b/lld/test/wasm/init-fini.ll @@ -25,6 +25,7 @@ declare hidden void @externCtor() declare hidden void @externDtor() +declare hidden void @__wasm_call_ctors() define i32 @__cxa_atexit(i32 %func, i32 %arg, i32 %dso_handle) { ret i32 0 @@ -32,6 +33,7 @@ define hidden void @_start() { entry: + call void @__wasm_call_ctors(); ret void } @@ -127,202 +129,22 @@ ; CHECK-NEXT: Name: .Lregister_call_dtors.2002 ; CHECK-NEXT: ... - ; RUN: wasm-ld -r %t.o %t.global-ctor-dtor.o -o %t.reloc.wasm -; RUN: obj2yaml %t.reloc.wasm | FileCheck -check-prefix=RELOC %s +; RUN: llvm-readobj --symbols --sections %t.reloc.wasm | FileCheck -check-prefix=RELOC %s -; RELOC: SymbolTable: -; RELOC-NEXT: - Index: 0 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: func1 -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: Function: 2 -; RELOC-NEXT: - Index: 1 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: func2 -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: Function: 3 -; RELOC-NEXT: - Index: 2 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: func3 -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: Function: 4 -; RELOC-NEXT: - Index: 3 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: func4 -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: Function: 5 -; RELOC-NEXT: - Index: 4 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: __cxa_atexit -; RELOC-NEXT: Flags: [ ] -; RELOC-NEXT: Function: 6 -; RELOC-NEXT: - Index: 5 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: _start -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: Function: 7 -; RELOC-NEXT: - Index: 6 -; RELOC-NEXT: Kind: DATA -; RELOC-NEXT: Name: __dso_handle -; RELOC-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN, UNDEFINED ] -; RELOC-NEXT: - Index: 7 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: externDtor -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ] -; RELOC-NEXT: Function: 0 -; RELOC-NEXT: - Index: 8 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: externCtor -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN, UNDEFINED ] -; RELOC-NEXT: Function: 1 -; RELOC-NEXT: - Index: 9 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: myctor -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: Function: 14 -; RELOC-NEXT: - Index: 10 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: mydtor -; RELOC-NEXT: Flags: [ VISIBILITY_HIDDEN ] -; RELOC-NEXT: Function: 15 -; RELOC-NEXT: - Index: 11 -; RELOC-NEXT: Kind: GLOBAL -; RELOC-NEXT: Name: __stack_pointer -; RELOC-NEXT: Flags: [ UNDEFINED ] -; RELOC-NEXT: Global: 0 -; RELOC-NEXT: - Index: 12 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lcall_dtors.101 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 8 -; RELOC-NEXT: - Index: 13 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lregister_call_dtors.101 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 9 -; RELOC-NEXT: - Index: 14 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lcall_dtors.1001 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 10 -; RELOC-NEXT: - Index: 15 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lregister_call_dtors.1001 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 11 -; RELOC-NEXT: - Index: 16 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lcall_dtors.4000 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 12 -; RELOC-NEXT: - Index: 17 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lregister_call_dtors.4000 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 13 -; RELOC-NEXT: - Index: 18 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lcall_dtors.101 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 16 -; RELOC-NEXT: - Index: 19 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lregister_call_dtors.101 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 17 -; RELOC-NEXT: - Index: 20 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lcall_dtors.202 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 18 -; RELOC-NEXT: - Index: 21 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lregister_call_dtors.202 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 19 -; RELOC-NEXT: - Index: 22 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lcall_dtors.2002 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 20 -; RELOC-NEXT: - Index: 23 -; RELOC-NEXT: Kind: FUNCTION -; RELOC-NEXT: Name: .Lregister_call_dtors.2002 -; RELOC-NEXT: Flags: [ BINDING_LOCAL ] -; RELOC-NEXT: Function: 21 -; RELOC-NEXT: InitFunctions: -; RELOC-NEXT: - Priority: 101 -; RELOC-NEXT: Symbol: 0 -; RELOC-NEXT: - Priority: 101 -; RELOC-NEXT: Symbol: 1 -; RELOC-NEXT: - Priority: 101 -; RELOC-NEXT: Symbol: 13 -; RELOC-NEXT: - Priority: 101 -; RELOC-NEXT: Symbol: 9 -; RELOC-NEXT: - Priority: 101 -; RELOC-NEXT: Symbol: 19 -; RELOC-NEXT: - Priority: 202 -; RELOC-NEXT: Symbol: 9 -; RELOC-NEXT: - Priority: 202 -; RELOC-NEXT: Symbol: 21 -; RELOC-NEXT: - Priority: 1001 -; RELOC-NEXT: Symbol: 0 -; RELOC-NEXT: - Priority: 1001 -; RELOC-NEXT: Symbol: 15 -; RELOC-NEXT: - Priority: 2002 -; RELOC-NEXT: Symbol: 9 -; RELOC-NEXT: - Priority: 2002 -; RELOC-NEXT: Symbol: 23 -; RELOC-NEXT: - Priority: 4000 -; RELOC-NEXT: Symbol: 8 -; RELOC-NEXT: - Priority: 4000 -; RELOC-NEXT: Symbol: 17 -; RELOC-NEXT: - Type: CUSTOM -; RELOC-NEXT: Name: name -; RELOC-NEXT: FunctionNames: -; RELOC-NEXT: - Index: 0 -; RELOC-NEXT: Name: externDtor -; RELOC-NEXT: - Index: 1 -; RELOC-NEXT: Name: externCtor -; RELOC-NEXT: - Index: 2 -; RELOC-NEXT: Name: func1 -; RELOC-NEXT: - Index: 3 -; RELOC-NEXT: Name: func2 -; RELOC-NEXT: - Index: 4 -; RELOC-NEXT: Name: func3 -; RELOC-NEXT: - Index: 5 -; RELOC-NEXT: Name: func4 -; RELOC-NEXT: - Index: 6 -; RELOC-NEXT: Name: __cxa_atexit -; RELOC-NEXT: - Index: 7 -; RELOC-NEXT: Name: _start -; RELOC-NEXT: - Index: 8 -; RELOC-NEXT: Name: .Lcall_dtors.101 -; RELOC-NEXT: - Index: 9 -; RELOC-NEXT: Name: .Lregister_call_dtors.101 -; RELOC-NEXT: - Index: 10 -; RELOC-NEXT: Name: .Lcall_dtors.1001 -; RELOC-NEXT: - Index: 11 -; RELOC-NEXT: Name: .Lregister_call_dtors.1001 -; RELOC-NEXT: - Index: 12 -; RELOC-NEXT: Name: .Lcall_dtors.4000 -; RELOC-NEXT: - Index: 13 -; RELOC-NEXT: Name: .Lregister_call_dtors.4000 -; RELOC-NEXT: - Index: 14 -; RELOC-NEXT: Name: myctor -; RELOC-NEXT: - Index: 15 -; RELOC-NEXT: Name: mydtor -; RELOC-NEXT: - Index: 16 -; RELOC-NEXT: Name: .Lcall_dtors.101 -; RELOC-NEXT: - Index: 17 -; RELOC-NEXT: Name: .Lregister_call_dtors.101 -; RELOC-NEXT: - Index: 18 -; RELOC-NEXT: Name: .Lcall_dtors.202 -; RELOC-NEXT: - Index: 19 -; RELOC-NEXT: Name: .Lregister_call_dtors.202 -; RELOC-NEXT: - Index: 20 -; RELOC-NEXT: Name: .Lcall_dtors.2002 -; RELOC-NEXT: - Index: 21 -; RELOC-NEXT: Name: .Lregister_call_dtors.2002 -; RELOC-NEXT: ... +; RELOC: Name: linking +; RELOC-NEXT: InitFunctions [ +; RELOC-NEXT: 0 (priority=101) +; RELOC-NEXT: 1 (priority=101) +; RELOC-NEXT: 14 (priority=101) +; RELOC-NEXT: 10 (priority=101) +; RELOC-NEXT: 20 (priority=101) +; RELOC-NEXT: 10 (priority=202) +; RELOC-NEXT: 22 (priority=202) +; RELOC-NEXT: 0 (priority=1001) +; RELOC-NEXT: 16 (priority=1001) +; RELOC-NEXT: 10 (priority=2002) +; RELOC-NEXT: 24 (priority=2002) +; RELOC-NEXT: 9 (priority=4000) +; RELOC-NEXT: 18 (priority=4000) +; RELOC-NEXT: ] diff --git a/lld/test/wasm/local-symbols.ll b/lld/test/wasm/local-symbols.ll --- a/lld/test/wasm/local-symbols.ll +++ b/lld/test/wasm/local-symbols.ll @@ -27,13 +27,13 @@ ; CHECK-NEXT: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 0 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: FUNCREF @@ -83,7 +83,7 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: foo ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 @@ -91,13 +91,10 @@ ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B -; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4100280284888080000B -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1081808080001A0B +; CHECK-NEXT: Body: 1080808080001A0B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: ; CHECK-NEXT: - SectionOffset: 7 @@ -110,9 +107,7 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: baz -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start ; CHECK-NEXT: ... diff --git a/lld/test/wasm/locals-duplicate.test b/lld/test/wasm/locals-duplicate.test --- a/lld/test/wasm/locals-duplicate.test +++ b/lld/test/wasm/locals-duplicate.test @@ -10,14 +10,11 @@ ; CHECK-NEXT: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: NORESULT -; CHECK-NEXT: ParamTypes: -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -; CHECK-NEXT: 1, 1, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +; CHECK-NEXT: 0, 0 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: FUNCREF @@ -73,63 +70,63 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: colliding_func2 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: get_global1A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: get_global2A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 5 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Name: colliding_global2 ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: get_global3A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 6 +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: - Name: get_func1A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 7 +; CHECK-NEXT: Index: 6 ; CHECK-NEXT: - Name: get_func2A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 8 +; CHECK-NEXT: Index: 7 ; CHECK-NEXT: - Name: get_func3A ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 9 +; CHECK-NEXT: Index: 8 ; CHECK-NEXT: - Name: colliding_func1 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 10 +; CHECK-NEXT: Index: 9 ; CHECK-NEXT: - Name: get_global1B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 13 +; CHECK-NEXT: Index: 12 ; CHECK-NEXT: - Name: colliding_global1 ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Name: get_global2B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 14 +; CHECK-NEXT: Index: 13 ; CHECK-NEXT: - Name: get_global3B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 15 +; CHECK-NEXT: Index: 14 ; CHECK-NEXT: - Name: get_func1B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 16 +; CHECK-NEXT: Index: 15 ; CHECK-NEXT: - Name: get_func2B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 17 +; CHECK-NEXT: Index: 16 ; CHECK-NEXT: - Name: get_func3B ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 18 +; CHECK-NEXT: Index: 17 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 1, 2, 3, 10, 11, 12 ] +; CHECK-NEXT: Functions: [ 0, 1, 2, 9, 10, 11 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 41020B @@ -138,25 +135,25 @@ ; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41020B +; CHECK-NEXT: Body: 4180888080000B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4180888080000B +; CHECK-NEXT: Body: 4184888080000B ; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4184888080000B +; CHECK-NEXT: Body: 4188888080000B ; CHECK-NEXT: - Index: 6 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4188888080000B +; CHECK-NEXT: Body: 4181808080000B ; CHECK-NEXT: - Index: 7 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4181808080000B +; CHECK-NEXT: Body: 4182808080000B ; CHECK-NEXT: - Index: 8 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4182808080000B +; CHECK-NEXT: Body: 4183808080000B ; CHECK-NEXT: - Index: 9 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4183808080000B +; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 10 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 41020B @@ -165,23 +162,20 @@ ; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 12 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41020B -; CHECK-NEXT: - Index: 13 -; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 418C888080000B -; CHECK-NEXT: - Index: 14 +; CHECK-NEXT: - Index: 13 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4190888080000B -; CHECK-NEXT: - Index: 15 +; CHECK-NEXT: - Index: 14 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4194888080000B -; CHECK-NEXT: - Index: 16 +; CHECK-NEXT: - Index: 15 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4184808080000B -; CHECK-NEXT: - Index: 17 +; CHECK-NEXT: - Index: 16 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4185808080000B -; CHECK-NEXT: - Index: 18 +; CHECK-NEXT: - Index: 17 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4186808080000B ; CHECK-NEXT: - Type: DATA @@ -196,42 +190,40 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: colliding_func1 -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: colliding_func2 -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: colliding_func3 -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: get_global1A -; CHECK-NEXT: - Index: 5 +; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Name: get_global2A -; CHECK-NEXT: - Index: 6 +; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Name: get_global3A -; CHECK-NEXT: - Index: 7 +; CHECK-NEXT: - Index: 6 ; CHECK-NEXT: Name: get_func1A -; CHECK-NEXT: - Index: 8 +; CHECK-NEXT: - Index: 7 ; CHECK-NEXT: Name: get_func2A -; CHECK-NEXT: - Index: 9 +; CHECK-NEXT: - Index: 8 ; CHECK-NEXT: Name: get_func3A -; CHECK-NEXT: - Index: 10 +; CHECK-NEXT: - Index: 9 ; CHECK-NEXT: Name: colliding_func1 -; CHECK-NEXT: - Index: 11 +; CHECK-NEXT: - Index: 10 ; CHECK-NEXT: Name: colliding_func2 -; CHECK-NEXT: - Index: 12 +; CHECK-NEXT: - Index: 11 ; CHECK-NEXT: Name: colliding_func3 -; CHECK-NEXT: - Index: 13 +; CHECK-NEXT: - Index: 12 ; CHECK-NEXT: Name: get_global1B -; CHECK-NEXT: - Index: 14 +; CHECK-NEXT: - Index: 13 ; CHECK-NEXT: Name: get_global2B -; CHECK-NEXT: - Index: 15 +; CHECK-NEXT: - Index: 14 ; CHECK-NEXT: Name: get_global3B -; CHECK-NEXT: - Index: 16 +; CHECK-NEXT: - Index: 15 ; CHECK-NEXT: Name: get_func1B -; CHECK-NEXT: - Index: 17 +; CHECK-NEXT: - Index: 16 ; CHECK-NEXT: Name: get_func2B -; CHECK-NEXT: - Index: 18 +; CHECK-NEXT: - Index: 17 ; CHECK-NEXT: Name: get_func3B ; CHECK-NEXT: ... diff --git a/lld/test/wasm/lto/archive.ll b/lld/test/wasm/lto/archive.ll --- a/lld/test/wasm/lto/archive.ll +++ b/lld/test/wasm/lto/archive.ll @@ -18,8 +18,6 @@ ; CHECK: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: f diff --git a/lld/test/wasm/lto/export.ll b/lld/test/wasm/lto/export.ll --- a/lld/test/wasm/lto/export.ll +++ b/lld/test/wasm/lto/export.ll @@ -31,8 +31,8 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: hidden_function ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Type: CODE diff --git a/lld/test/wasm/lto/lto-start.ll b/lld/test/wasm/lto/lto-start.ll --- a/lld/test/wasm/lto/lto-start.ll +++ b/lld/test/wasm/lto/lto-start.ll @@ -6,8 +6,6 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" diff --git a/lld/test/wasm/lto/used.ll b/lld/test/wasm/lto/used.ll --- a/lld/test/wasm/lto/used.ll +++ b/lld/test/wasm/lto/used.ll @@ -38,8 +38,6 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: bar diff --git a/lld/test/wasm/shared.ll b/lld/test/wasm/shared.ll --- a/lld/test/wasm/shared.ll +++ b/lld/test/wasm/shared.ll @@ -68,7 +68,7 @@ ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: GLOBAL_GET ; CHECK-NEXT: Index: 2 -; CHECK-NEXT: Functions: [ 2, 0 ] +; CHECK-NEXT: Functions: [ 1, 0 ] ; check the data segment initialized with __memory_base global as offset diff --git a/lld/test/wasm/signature-mismatch-export.ll b/lld/test/wasm/signature-mismatch-export.ll --- a/lld/test/wasm/signature-mismatch-export.ll +++ b/lld/test/wasm/signature-mismatch-export.ll @@ -16,17 +16,15 @@ ; CHECK: - Type: EXPORT ; CHECK: - Name: ret32 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: 'unreachable:ret32' -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: ret32 ; CHECK-NEXT: ... diff --git a/lld/test/wasm/signature-mismatch.ll b/lld/test/wasm/signature-mismatch.ll --- a/lld/test/wasm/signature-mismatch.ll +++ b/lld/test/wasm/signature-mismatch.ll @@ -31,23 +31,21 @@ ; YAML: - Type: EXPORT ; YAML: - Name: ret32 ; YAML-NEXT: Kind: FUNCTION -; YAML-NEXT: Index: 3 +; YAML-NEXT: Index: 2 ; YAML-NEXT: - Name: call_ret32 ; YAML-NEXT: Kind: FUNCTION -; YAML-NEXT: Index: 4 +; YAML-NEXT: Index: 3 ; YAML: - Type: CUSTOM ; YAML-NEXT: Name: name ; YAML-NEXT: FunctionNames: ; YAML-NEXT: - Index: 0 -; YAML-NEXT: Name: __wasm_call_ctors -; YAML-NEXT: - Index: 1 ; YAML-NEXT: Name: 'unreachable:ret32' -; YAML-NEXT: - Index: 2 +; YAML-NEXT: - Index: 1 ; YAML-NEXT: Name: _start -; YAML-NEXT: - Index: 3 +; YAML-NEXT: - Index: 2 ; YAML-NEXT: Name: ret32 -; YAML-NEXT: - Index: 4 +; YAML-NEXT: - Index: 3 ; YAML-NEXT: Name: call_ret32 ; YAML-NEXT: ... diff --git a/lld/test/wasm/undefined-weak-call.ll b/lld/test/wasm/undefined-weak-call.ll --- a/lld/test/wasm/undefined-weak-call.ll +++ b/lld/test/wasm/undefined-weak-call.ll @@ -42,7 +42,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 1, 2 ] +; CHECK-NEXT: FunctionTypes: [ 0, 0, 1, 2 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: FUNCREF @@ -86,12 +86,12 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: callWeakFuncs ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 000B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 000B @@ -100,21 +100,16 @@ ; CHECK-NEXT: Body: 000B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 000B -; CHECK-NEXT: - Index: 4 -; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 10818080800010828080800041021083808080004180808080004180808080006A0B +; CHECK-NEXT: Body: 10808080800010818080800041021082808080004180808080004180808080006A0B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: 'undefined:weakFunc1' -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: 'undefined:weakFunc2' -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: 'undefined:weakFunc3' -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: callWeakFuncs ; CHECK-NEXT: ... diff --git a/lld/test/wasm/visibility-hidden.ll b/lld/test/wasm/visibility-hidden.ll --- a/lld/test/wasm/visibility-hidden.ll +++ b/lld/test/wasm/visibility-hidden.ll @@ -51,13 +51,13 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: objectDefault ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: archiveDefault ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 5 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Type: @@ -74,5 +74,5 @@ ; NO-DEFAULT-NEXT: Index: 2 ; NO-DEFAULT-NEXT: - Name: _start ; NO-DEFAULT-NEXT: Kind: FUNCTION -; NO-DEFAULT-NEXT: Index: 3 +; NO-DEFAULT-NEXT: Index: 2 ; NO-DEFAULT-NEXT: - Type: diff --git a/lld/test/wasm/weak-alias-overide.ll b/lld/test/wasm/weak-alias-overide.ll --- a/lld/test/wasm/weak-alias-overide.ll +++ b/lld/test/wasm/weak-alias-overide.ll @@ -26,13 +26,13 @@ ; CHECK-NEXT: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 0, 1, 1, 1, 1, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1, 0, 0, 0, 0, 0 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: FUNCREF @@ -76,78 +76,73 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: alias_fn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: direct_fn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: call_direct ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: call_alias ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 5 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Name: call_alias_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 6 +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: - Name: call_direct_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 7 +; CHECK-NEXT: Index: 6 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 1, 3 ] +; CHECK-NEXT: Functions: [ 0, 2 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 41010B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41010B +; CHECK-NEXT: Body: 1080808080001A0B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1081808080001A0B +; CHECK-NEXT: Body: 41000B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41000B +; CHECK-NEXT: Body: 1082808080000B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1083808080000B +; CHECK-NEXT: Body: 1080808080000B ; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1081808080000B -; CHECK-NEXT: - Index: 6 -; CHECK-NEXT: Locals: ; CHECK-NEXT: - Type: I32 ; CHECK-NEXT: Count: 2 -; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B -; CHECK-NEXT: - Index: 7 +; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081080808080002101200041106A24808080800020010B +; CHECK-NEXT: - Index: 6 ; CHECK-NEXT: Locals: ; CHECK-NEXT: - Type: I32 ; CHECK-NEXT: Count: 2 -; CHECK-NEXT: Body: 23808080800041106B220024808080800020004182808080003602081083808080002101200041106A24808080800020010B +; CHECK-NEXT: Body: 23808080800041106B220024808080800020004182808080003602081082808080002101200041106A24808080800020010B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: alias_fn -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: direct_fn -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: call_direct -; CHECK-NEXT: - Index: 5 +; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Name: call_alias -; CHECK-NEXT: - Index: 6 +; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Name: call_alias_ptr -; CHECK-NEXT: - Index: 7 +; CHECK-NEXT: - Index: 6 ; CHECK-NEXT: Name: call_direct_ptr ; CHECK-NEXT: ... diff --git a/lld/test/wasm/weak-alias.ll b/lld/test/wasm/weak-alias.ll --- a/lld/test/wasm/weak-alias.ll +++ b/lld/test/wasm/weak-alias.ll @@ -29,7 +29,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 1, 1, 1, 1, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: FUNCREF @@ -73,74 +73,69 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: alias_fn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: direct_fn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: call_direct ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: call_alias ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: call_alias_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 5 +; CHECK-NEXT: Index: 4 ; CHECK-NEXT: - Name: call_direct_ptr ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 6 +; CHECK-NEXT: Index: 5 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 2 ] +; CHECK-NEXT: Functions: [ 1 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 1081808080001A0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1082808080001A0B +; CHECK-NEXT: Body: 41000B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 41000B +; CHECK-NEXT: Body: 1081808080000B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1082808080000B +; CHECK-NEXT: Body: 1081808080000B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1082808080000B -; CHECK-NEXT: - Index: 5 -; CHECK-NEXT: Locals: ; CHECK-NEXT: - Type: I32 ; CHECK-NEXT: Count: 2 -; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081082808080002101200041106A24808080800020010B -; CHECK-NEXT: - Index: 6 +; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B +; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: ; CHECK-NEXT: - Type: I32 ; CHECK-NEXT: Count: 2 -; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081082808080002101200041106A24808080800020010B +; CHECK-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: direct_fn -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: call_direct -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: call_alias -; CHECK-NEXT: - Index: 5 +; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Name: call_alias_ptr -; CHECK-NEXT: - Index: 6 +; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Name: call_direct_ptr ; CHECK-NEXT: ... diff --git a/lld/test/wasm/weak-symbols.ll b/lld/test/wasm/weak-symbols.ll --- a/lld/test/wasm/weak-symbols.ll +++ b/lld/test/wasm/weak-symbols.ll @@ -29,7 +29,7 @@ ; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 0, 1, 1, 1 ] +; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: FUNCREF @@ -79,40 +79,37 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: weakFn ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 2 +; CHECK-NEXT: Index: 1 ; CHECK-NEXT: - Name: exportWeak1 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: weakGlobal ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Name: exportWeak2 ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Index: 3 ; CHECK-NEXT: - Type: ELEM ; CHECK-NEXT: Segments: ; CHECK-NEXT: - Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 1 -; CHECK-NEXT: Functions: [ 2 ] +; CHECK-NEXT: Functions: [ 1 ] ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 1081808080001A0B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1082808080001A0B -; CHECK-NEXT: - Index: 2 -; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 41010B -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4181808080000B -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4181808080000B ; CHECK-NEXT: - Type: DATA @@ -127,13 +124,11 @@ ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: Name: __wasm_call_ctors -; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: _start -; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: weakFn -; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: exportWeak1 -; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: exportWeak2 ; CHECK-NEXT: ... diff --git a/lld/test/wasm/weak-undefined.ll b/lld/test/wasm/weak-undefined.ll --- a/lld/test/wasm/weak-undefined.ll +++ b/lld/test/wasm/weak-undefined.ll @@ -34,13 +34,13 @@ ; CHECK-NEXT: - Type: TYPE ; CHECK-NEXT: Signatures: ; CHECK-NEXT: - Index: 0 -; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ReturnType: I32 ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Index: 1 -; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ReturnType: NORESULT ; CHECK-NEXT: ParamTypes: ; CHECK-NEXT: - Type: FUNCTION -; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 0 ] +; CHECK-NEXT: FunctionTypes: [ 0, 0, 1 ] ; CHECK-NEXT: - Type: TABLE ; CHECK-NEXT: Tables: ; CHECK-NEXT: - ElemType: FUNCREF @@ -84,19 +84,16 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Name: _start ; CHECK-NEXT: Kind: FUNCTION -; CHECK-NEXT: Index: 3 +; CHECK-NEXT: Index: 2 ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 0B +; CHECK-NEXT: Body: 4180808080000B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4180808080000B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4180808080000B -; CHECK-NEXT: - Index: 3 -; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 1082808080001A1081808080001A0B +; CHECK-NEXT: Body: 1081808080001A1080808080001A0B ; CHECK-NEXT: ... diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp --- a/lld/wasm/MarkLive.cpp +++ b/lld/wasm/MarkLive.cpp @@ -38,32 +38,42 @@ LLVM_DEBUG(dbgs() << "markLive\n"); SmallVector Q; - auto Enqueue = [&](Symbol *Sym) { + std::function Enqueue = [&](Symbol *Sym) { if (!Sym || Sym->isLive()) return; LLVM_DEBUG(dbgs() << "markLive: " << Sym->getName() << "\n"); Sym->markLive(); if (InputChunk *Chunk = Sym->getChunk()) Q.push_back(Chunk); + + // The ctor functions are all referenced by the synthetic CallCtors + // function. However, this function does not contain relocations so we + // have to manually mark the ctors as live if CallCtors itself is live. + if (Sym == WasmSym::CallCtors) { + for (const ObjFile *Obj : Symtab->ObjectFiles) { + const WasmLinkingData &L = Obj->getWasmObj()->linkingData(); + for (const WasmInitFunc &F : L.InitFunctions) + Enqueue(Obj->getFunctionSymbol(F.Symbol)); + } + } }; // Add GC root symbols. if (!Config->Entry.empty()) Enqueue(Symtab->find(Config->Entry)); - Enqueue(WasmSym::CallCtors); // We need to preserve any exported symbol for (Symbol *Sym : Symtab->getSymbols()) if (Sym->isExported()) Enqueue(Sym); - // The ctor functions are all used in the synthetic __wasm_call_ctors - // function, but since this function is created in-place it doesn't contain - // relocations which mean we have to manually mark the ctors. - for (const ObjFile *Obj : Symtab->ObjectFiles) { - const WasmLinkingData &L = Obj->getWasmObj()->linkingData(); - for (const WasmInitFunc &F : L.InitFunctions) - Enqueue(Obj->getFunctionSymbol(F.Symbol)); + // For relocatable output, we need to preserve all the ctor functions + if (Config->Relocatable) { + for (const ObjFile *Obj : Symtab->ObjectFiles) { + const WasmLinkingData &L = Obj->getWasmObj()->linkingData(); + for (const WasmInitFunc &F : L.InitFunctions) + Enqueue(Obj->getFunctionSymbol(F.Symbol)); + } } // Follow relocations to mark all reachable chunks. diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -1137,6 +1137,9 @@ // Create synthetic "__wasm_call_ctors" function based on ctor functions // in input object. void Writer::createCtorFunction() { + if (!WasmSym::CallCtors->isLive()) + return; + // First write the body's contents to a string. std::string BodyContent; { @@ -1169,6 +1172,7 @@ const WasmLinkingData &L = File->getWasmObj()->linkingData(); for (const WasmInitFunc &F : L.InitFunctions) { FunctionSymbol *Sym = File->getFunctionSymbol(F.Symbol); + assert(Sym->isLive()); if (*Sym->Signature != WasmSignature{{}, {}}) error("invalid signature for init func: " + toString(*Sym)); InitFunctions.emplace_back(WasmInitEntry{Sym, F.Priority});