From 59ceb985c7f78ca5dba6b83ff126d97d86267d7c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 14 Apr 2021 12:44:04 -0400 Subject: [PATCH] cmd/link: make Loader.SymName not crash Even if not presented with a valid symbol, recover gracefully, so that debug prints do not crash. Change-Id: I06bbe4bec5f90b79b4830e772a7fc3d7c919df1b Reviewed-on: https://go-review.googlesource.com/c/go/+/312036 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Cherry Zhang --- src/cmd/link/internal/loader/loader.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go index 141dd0ac688..d5331b3fef1 100644 --- a/src/cmd/link/internal/loader/loader.go +++ b/src/cmd/link/internal/loader/loader.go @@ -771,6 +771,9 @@ func (l *Loader) SymName(i Sym) string { return pp.name } r, li := l.toLocal(i) + if r == nil { + return "?" + } name := r.Sym(li).Name(r.Reader) if !r.NeedNameExpansion() { return name