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

[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 <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2020-05-06 12:06:52 -04:00
parent dc048e24ab
commit 2867a85541
2 changed files with 0 additions and 45 deletions

View File

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

View File

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