1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:34:53 -07:00

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 <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Joel Sing 2022-09-13 19:28:58 +10:00 committed by Gopher Robot
parent f7396aaea0
commit 77420fa119

View File

@ -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