diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2017-04-18 12:53:25 -0700 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2017-04-19 00:00:09 +0000 |
| commit | 1e3570ac86f6aeb7f8ce70b5ad236a5dd92ec804 (patch) | |
| tree | 6bb1e704f068dee9f7e95eb0d1b5ed1829441c8b /src/cmd/link/internal/ld/deadcode.go | |
| parent | f71f32e5e155ae5b7f60005c939746637086f30e (diff) | |
| download | go-1e3570ac86f6aeb7f8ce70b5ad236a5dd92ec804.tar.xz | |
cmd/internal/objabi: extract shared functionality from obj
Now only cmd/asm and cmd/compile depend on cmd/internal/obj. Changing
the assembler backends no longer requires reinstalling cmd/link or
cmd/addr2line.
There's also now one canonical definition of the object file format in
cmd/internal/objabi/doc.go, with a warning to update all three
implementations.
objabi is still something of a grab bag of unrelated code (e.g., flag
and environment variable handling probably belong in a separate "tool"
package), but this is still progress.
Fixes #15165.
Fixes #20026.
Change-Id: Ic4b92fac7d0d35438e0d20c9579aad4085c5534c
Reviewed-on: https://go-review.googlesource.com/40972
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode.go')
| -rw-r--r-- | src/cmd/link/internal/ld/deadcode.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index c616d5d5a8..a7b9cb3a3a 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -5,7 +5,7 @@ package ld import ( - "cmd/internal/obj" + "cmd/internal/objabi" "cmd/internal/sys" "fmt" "strings" @@ -46,7 +46,7 @@ import ( // Any unreached text symbols are removed from ctxt.Textp. func deadcode(ctxt *Link) { if ctxt.Debugvlog != 0 { - ctxt.Logf("%5.2f deadcode\n", obj.Cputime()) + ctxt.Logf("%5.2f deadcode\n", Cputime()) } d := &deadcodepass{ @@ -156,7 +156,7 @@ type deadcodepass struct { func (d *deadcodepass) cleanupReloc(r *Reloc) { if r.Sym.Attr.Reachable() { - r.Type = obj.R_ADDROFF + r.Type = objabi.R_ADDROFF } else { if d.ctxt.Debugvlog > 1 { d.ctxt.Logf("removing method %s\n", r.Sym.Name) @@ -190,7 +190,7 @@ func (d *deadcodepass) mark(s, parent *Symbol) { func (d *deadcodepass) markMethod(m methodref) { for _, r := range m.r { d.mark(r.Sym, m.src) - r.Type = obj.R_ADDROFF + r.Type = objabi.R_ADDROFF } } @@ -208,7 +208,7 @@ func (d *deadcodepass) init() { // Mark all symbols defined in this library as reachable when // building a shared library. for _, s := range d.ctxt.Syms.Allsym { - if s.Type != 0 && s.Type != obj.SDYNIMPORT { + if s.Type != 0 && s.Type != objabi.SDYNIMPORT { d.mark(s, nil) } } @@ -246,7 +246,7 @@ func (d *deadcodepass) flood() { for len(d.markQueue) > 0 { s := d.markQueue[0] d.markQueue = d.markQueue[1:] - if s.Type == obj.STEXT { + if s.Type == objabi.STEXT { if d.ctxt.Debugvlog > 1 { d.ctxt.Logf("marktext %s\n", s.Name) } @@ -281,13 +281,13 @@ func (d *deadcodepass) flood() { if r.Sym == nil { continue } - if r.Type == obj.R_WEAKADDROFF { + if r.Type == objabi.R_WEAKADDROFF { // An R_WEAKADDROFF relocation is not reason // enough to mark the pointed-to symbol as // reachable. continue } - if r.Type != obj.R_METHODOFF { + if r.Type != objabi.R_METHODOFF { d.mark(r.Sym, s) continue } |
