From 2867a855413ac7cb10c1e5ca5b68f15c0125b40f Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 6 May 2020 12:06:52 -0400 Subject: [PATCH] [dev.link] cmd/link: delete undef pass The undef pass basically double-checks the relocation targets are defined. We already do that in the reloc pass, and for external relocations we check that when we emit relocations. The undef pass doesn't seem necessary. Change-Id: Iecfa654dc014fdc6e59c624cbf5948ad65fd367a Reviewed-on: https://go-review.googlesource.com/c/go/+/232577 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Jeremy Faller Reviewed-by: Than McIntosh --- src/cmd/link/internal/ld/lib.go | 43 -------------------------------- src/cmd/link/internal/ld/main.go | 2 -- 2 files changed, 45 deletions(-) diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index c5c38d4b47..a612bfadec 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -2692,49 +2692,6 @@ func Entryvalue(ctxt *Link) int64 { return s.Value } -func undefsym(ctxt *Link, s *sym.Symbol) { - var r *sym.Reloc - - for i := 0; i < len(s.R); i++ { - r = &s.R[i] - if r.Sym == nil { // happens for some external ARM relocs - continue - } - // TODO(mwhudson): the test of VisibilityHidden here probably doesn't make - // sense and should be removed when someone has thought about it properly. - if (r.Sym.Type == sym.Sxxx || r.Sym.Type == sym.SXREF) && !r.Sym.Attr.VisibilityHidden() { - Errorf(s, "undefined: %q", r.Sym.Name) - } - if !r.Sym.Attr.Reachable() && r.Type != objabi.R_WEAKADDROFF { - Errorf(s, "relocation target %q", r.Sym.Name) - } - } -} - -func (ctxt *Link) undef() { - // undefsym performs checks (almost) identical to checks - // that report undefined relocations in relocsym. - // Both undefsym and relocsym can report same symbol as undefined, - // which results in error message duplication (see #10978). - // - // The undef is run after Arch.Asmb and could detect some - // programming errors there, but if object being linked is already - // failed with errors, it is better to avoid duplicated errors. - if nerrors > 0 { - return - } - - for _, s := range ctxt.Textp { - undefsym(ctxt, s) - } - for _, s := range ctxt.datap { - undefsym(ctxt, s) - } - if nerrors > 0 { - errorexit() - } -} - func (ctxt *Link) callgraph() { if !*FlagC { return diff --git a/src/cmd/link/internal/ld/main.go b/src/cmd/link/internal/ld/main.go index 80be4d95be..7d3f25540d 100644 --- a/src/cmd/link/internal/ld/main.go +++ b/src/cmd/link/internal/ld/main.go @@ -343,8 +343,6 @@ func Main(arch *sys.Arch, theArch Arch) { bench.Start("Munmap") ctxt.Out.Close() // Close handles Munmapping if necessary. - bench.Start("undef") - ctxt.undef() bench.Start("hostlink") ctxt.hostlink() if ctxt.Debugvlog != 0 { -- 2.48.1