diff options
| author | Cherry Zhang <cherryyz@google.com> | 2019-10-04 22:05:41 -0400 |
|---|---|---|
| committer | Cherry Zhang <cherryyz@google.com> | 2019-10-15 18:55:32 +0000 |
| commit | cab29ebd84d3fae2092337684ba82999fe97e947 (patch) | |
| tree | b26ffb58eff691b5c6a83c763be6de1aa430835d /src/cmd/link/internal/ld/deadcode.go | |
| parent | 90fe9c7c5c19cd0816c8afaa65a7f14d18cd3860 (diff) | |
| download | go-cab29ebd84d3fae2092337684ba82999fe97e947.tar.xz | |
[dev.link] cmd/link: create sym.Symbols after deadcode in newobj mode
With the new object files, now we can run the deadcode pass on
indices instead of Symbol structs, so we can delay creating
Symbols after the deadcode pass. Then we only need to create
reachable symbols.
Not create Symbols in LoadNew and LoadRefs, and recombine
LoadReloc into LoadFull.
Split loadcgo into two parts: the first finds root symbols, the
second create Symbols and sets attributes. The first runs before
the deadcode pass, while the second runs after.
TODO: currently there are still symbols that are not marked
reachable but still used. This includes DWARF symbols, file
symbols, and type symbols that are referenced by DWARF symbols.
We still need to create them (conservatively).
Change-Id: I695779c9312be9d49ab1683957ac3e72e1f65a1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/199643
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode.go')
| -rw-r--r-- | src/cmd/link/internal/ld/deadcode.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index d0896fcf2c..1ff34fec5f 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -65,8 +65,8 @@ func deadcode(ctxt *Link) { d.init() d.flood() - callSym := ctxt.Lookup("reflect.Value.Call", sym.SymVerABIInternal) - methSym := ctxt.Lookup("reflect.Value.Method", sym.SymVerABIInternal) + callSym := ctxt.Syms.ROLookup("reflect.Value.Call", sym.SymVerABIInternal) + methSym := ctxt.Syms.ROLookup("reflect.Value.Method", sym.SymVerABIInternal) reflectSeen := false if ctxt.DynlinkingGo() { @@ -292,7 +292,7 @@ func (d *deadcodepass) init() { // We don't keep the go.plugin.exports symbol, // but we do keep the symbols it refers to. - exports := d.ctxt.Lookup("go.plugin.exports", 0) + exports := d.ctxt.Syms.ROLookup("go.plugin.exports", 0) if exports != nil { for i := range exports.R { d.mark(exports.R[i].Sym, nil) @@ -307,9 +307,9 @@ func (d *deadcodepass) init() { for _, name := range names { // Mark symbol as an data/ABI0 symbol. - d.mark(d.ctxt.Lookup(name, 0), nil) + d.mark(d.ctxt.Syms.ROLookup(name, 0), nil) // Also mark any Go functions (internal ABI). - d.mark(d.ctxt.Lookup(name, sym.SymVerABIInternal), nil) + d.mark(d.ctxt.Syms.ROLookup(name, sym.SymVerABIInternal), nil) } } |
