diff options
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode2.go')
| -rw-r--r-- | src/cmd/link/internal/ld/deadcode2.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/cmd/link/internal/ld/deadcode2.go b/src/cmd/link/internal/ld/deadcode2.go index ff5cb60a60..259199eea1 100644 --- a/src/cmd/link/internal/ld/deadcode2.go +++ b/src/cmd/link/internal/ld/deadcode2.go @@ -18,9 +18,6 @@ import ( var _ = fmt.Print // TODO: -// - Shared object support: -// It basically marks everything. We could consider using -// a different mechanism to represent it. // - Field tracking support: // It needs to record from where the symbol is referenced. // - Debug output: @@ -46,6 +43,19 @@ func (d *deadcodePass2) init() { d.ldr.InitReachable() d.ifaceMethod = make(map[methodsig]bool) + if d.ctxt.BuildMode == BuildModeShared { + // Mark all symbols defined in this library as reachable when + // building a shared library. + n := d.ldr.NDef() + for i := 1; i < n; i++ { + s := loader.Sym(i) + if !d.ldr.IsDup(s) { + d.mark(s) + } + } + return + } + var names []string // In a normal binary, start at main.main and the init |
