]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: generate an error if the entry symbol cannot be found
authorJoel Sing <joel@sing.id.au>
Tue, 13 Sep 2022 09:28:58 +0000 (19:28 +1000)
committerGopher Robot <gobot@golang.org>
Tue, 13 Sep 2022 17:39:33 +0000 (17:39 +0000)
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>
src/cmd/link/internal/ld/lib.go

index 14dc5433fb521829ed357c141acf89557b4d09ee..ca343ab2f97d51f9a83449ca0bfa5ecfcb274f50 100644 (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