]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: delete undef pass
authorCherry Zhang <cherryyz@google.com>
Wed, 6 May 2020 16:06:52 +0000 (12:06 -0400)
committerCherry Zhang <cherryyz@google.com>
Wed, 6 May 2020 20:05:51 +0000 (20:05 +0000)
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>
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/main.go

index c5c38d4b47fe2cddb82700db7c3b24fd903de2ae..a612bfadecedd9d385ca60488d1ea354e581b971 100644 (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
index 80be4d95beec493ea973a03eacbc831efa95c2e7..7d3f25540d942080d6b52f44afd816160c58f481 100644 (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 {