From 8a0cf719a626ebd1ec11531ebaeacccbd19178ec Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 9 Sep 2022 12:29:48 -0400 Subject: [PATCH] cmd/link/internal/ld: panic if inlined functions missing FuncInfo All inlined functions are Go functions, and thus should be capable of having a FuncInfo. Missing FuncInfo is likely indication of a compiler bug that dropped the symbol too early, failing to add it to the symbol list used for writing output. I believe all existing cases have been fixed; this check will prevent regressions. The exception is -linkshared mode. There symbols are loaded from the shared library, and the FuncInfo is not available. This is a bug, as it can result in incorrect the FuncID in inlinedCall, but it is very involved to fix. For #54959. For #55954. Change-Id: Ib0dc4f1ea62525b55f68604d6013ff33223fdcdd Reviewed-on: https://go-review.googlesource.com/c/go/+/429637 TryBot-Result: Gopher Robot Reviewed-by: Matthew Dempsky Run-TryBot: Michael Pratt Reviewed-by: Cherry Mui --- src/cmd/link/internal/ld/pcln.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cmd/link/internal/ld/pcln.go b/src/cmd/link/internal/ld/pcln.go index 2a1e15cddb..2f13a24e04 100644 --- a/src/cmd/link/internal/ld/pcln.go +++ b/src/cmd/link/internal/ld/pcln.go @@ -171,7 +171,18 @@ func genInlTreeSym(ctxt *Link, cu *sym.CompilationUnit, fi loader.FuncInfo, arch var funcID objabi.FuncID if inlFunc.Valid() { funcID = inlFunc.FuncID() + } else if !ctxt.linkShared { + // Inlined functions are always Go functions, and thus + // must have FuncInfo. + // + // Unfortunately, with -linkshared, the inlined + // function may be external symbols (from another + // shared library), and we don't load FuncInfo from the + // shared library. We will report potentially incorrect + // FuncID in this case. See https://go.dev/issue/55954. + panic(fmt.Sprintf("inlined function %s missing func info", ldr.SymName(call.Func))) } + // Construct runtime.inlinedCall value. const size = 12 inlTreeSym.SetUint8(arch, int64(i*size+0), uint8(funcID)) -- 2.50.0