diff options
| author | David Crawshaw <crawshaw@golang.org> | 2016-11-21 16:58:55 -0500 |
|---|---|---|
| committer | David Crawshaw <crawshaw@golang.org> | 2016-11-22 03:10:14 +0000 |
| commit | 6f31abd23a6f768c21c8b308f355f3a1bae521d2 (patch) | |
| tree | e15962050a703354bb4d5636794112f14ea2b680 /src/cmd/link/internal/ld/deadcode.go | |
| parent | aeaa4c3c1da9e7a4afd4152913d6f2bfcf4fad2d (diff) | |
| download | go-6f31abd23a6f768c21c8b308f355f3a1bae521d2.tar.xz | |
cmd/compile, cmd/link: weak relocation for ptrTo
Introduce R_WEAKADDROFF, a "weak" variation of the R_ADDROFF relocation
that will only reference the type described if it is in some other way
reachable.
Use this for the ptrToThis field in reflect type information where it
is safe to do so (that is, types that don't need to be included for
interface satisfaction, and types that won't cause the compiler to
recursively generate an endless series of ptr-to-ptr-to-ptr-to...
types).
Also fix a small bug in reflect, where StructOf was not clearing the
ptrToThis field of new types.
Fixes #17931
Change-Id: I4d3b53cb9c916c97b3b16e367794eee142247281
Reviewed-on: https://go-review.googlesource.com/33427
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode.go')
| -rw-r--r-- | src/cmd/link/internal/ld/deadcode.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index c0c0c6bcf4..ae516818f5 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -308,6 +308,12 @@ func (d *deadcodepass) flood() { if r.Sym == nil { continue } + if r.Type == obj.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 { d.mark(r.Sym, s) continue |
