From 77420fa119643163f820be7752668a69100487d7 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Tue, 13 Sep 2022 19:28:58 +1000 Subject: [PATCH] cmd/link: generate an error if the entry symbol cannot be found If the entry symbol cannot be found (for example, a new port is being brought up and no rt0 code has been provided), the linker will currently panic. Rather than panicing, generate an error that aids in debugging: missing entry symbol "_rt0_arm64_openbsd" Change-Id: I9cc38eaab48f730d596ca7fa9e9e3d68250ae4d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/430555 Auto-Submit: Jenny Rakoczy TryBot-Result: Gopher Robot Reviewed-by: Jenny Rakoczy Run-TryBot: Cherry Mui Reviewed-by: Cherry Mui --- src/cmd/link/internal/ld/lib.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 14dc5433fb..ca343ab2f9 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -2435,6 +2435,10 @@ func Entryvalue(ctxt *Link) int64 { } ldr := ctxt.loader s := ldr.Lookup(a, 0) + if s == 0 { + Errorf(nil, "missing entry symbol %q", a) + return 0 + } st := ldr.SymType(s) if st == 0 { return *FlagTextAddr -- 2.50.0