[dev.link] cmd/link: move more error handling into loader

Move the guts of ctxt.Errorf into loader.Loader, so that we can make
calls to it from functions that have a "*loader.Loader" available but
not a "ctxt *Link". This is needed to start converting hooks like
"adddynrel" in the arch-specific portions of the linker to use loader
APIs.

Change-Id: Ieedd4583b66504be0e77d7f3fbadafe0d2307a69
Reviewed-on: https://go-review.googlesource.com/c/go/+/229497
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Than McIntosh 2020-04-22 15:16:06 -04:00
parent 442fd182fb
commit 3d1007d28e
6 changed files with 70 additions and 42 deletions

View file

@ -503,7 +503,7 @@ func (ctxt *Link) loadlib() {
default:
log.Fatalf("invalid -strictdups flag value %d", *FlagStrictDups)
}
ctxt.loader = loader.NewLoader(flags, elfsetstring)
ctxt.loader = loader.NewLoader(flags, elfsetstring, &ctxt.ErrorReporter.ErrorReporter)
ctxt.ErrorReporter.SymName = func(s loader.Sym) string {
return ctxt.loader.SymName(s)
}