diff options
| author | Cherry Zhang <cherryyz@google.com> | 2020-04-10 19:13:01 -0400 |
|---|---|---|
| committer | Cherry Zhang <cherryyz@google.com> | 2020-04-13 17:48:39 +0000 |
| commit | 14cf804aa047cfdb7be90098d53030773fc1424d (patch) | |
| tree | d8b34113e60bff0f3b4ef3e725f6a957b28896f9 /src/cmd/link/internal/ld/deadcode.go | |
| parent | 2820bcede0ec2f1ec1957e40dab183a18196559b (diff) | |
| download | go-14cf804aa047cfdb7be90098d53030773fc1424d.tar.xz | |
[dev.link] cmd/link: stop populating lib/unit.Textp
lib.Textp was used for text address assignment and trampoline
insertion. Now that it has been converted to using the loader,
no need to populate lib.Textp.
Port the logic of canonicalizing dupok symbol's package to the
loader.
unit.Textp was used for DWARF generation, which has also been
converted to using the loader.
Change-Id: I22d4dd30a52a29dd5b1b7b795d43a19f6215e4ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/228140
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 | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index 13ddcdac24..e5bd73cd94 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -5,7 +5,6 @@ package ld import ( - "cmd/internal/objabi" "cmd/link/internal/sym" ) @@ -46,11 +45,9 @@ func deadcode(ctxt *Link) { } // addToTextp populates the context Textp slice (needed in various places -// in the linker) and also the unit Textp slices (needed by the "old" -// phase 2 DWARF generation). +// in the linker). func addToTextp(ctxt *Link) { - - // First set up ctxt.Textp, based on ctxt.Textp2. + // Set up ctxt.Textp, based on ctxt.Textp2. textp := make([]*sym.Symbol, 0, len(ctxt.Textp2)) haveshlibs := len(ctxt.Shlibs) > 0 for _, tsym := range ctxt.Textp2 { @@ -64,37 +61,4 @@ func addToTextp(ctxt *Link) { textp = append(textp, sp) } ctxt.Textp = textp - - // Dupok symbols may be defined in multiple packages; the - // associated package for a dupok sym is chosen sort of - // arbitrarily (the first containing package that the linker - // loads). The loop below canonicalizes the File to the package - // with which it will be laid down in text. Assumes that - // ctxt.Library is already in postorder. - for _, doInternal := range [2]bool{true, false} { - for _, lib := range ctxt.Library { - if isRuntimeDepPkg(lib.Pkg) != doInternal { - continue - } - for _, dsym := range lib.DupTextSyms2 { - tsp := ctxt.loader.Syms[dsym] - if !tsp.Attr.OnList() { - tsp.Attr |= sym.AttrOnList - tsp.File = objabi.PathToPrefix(lib.Pkg) - } - } - } - } - - // Finally, set up compilation unit Textp slices. Can be removed - // once loader-Sym DWARF-gen phase 2 is always enabled. - for _, lib := range ctxt.Library { - for _, unit := range lib.Units { - for _, usym := range unit.Textp2 { - usp := ctxt.loader.Syms[usym] - usp.Attr |= sym.AttrOnList - unit.Textp = append(unit.Textp, usp) - } - } - } } |
