aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzhouguangyuan <zhouguangyuan.xian@gmail.com>2021-09-16 02:10:17 +0800
committerDmitri Shuralyov <dmitshur@golang.org>2021-10-28 16:34:40 +0000
commit91aa2f190aa07addb964afa48f98466bdb1a8556 (patch)
treec72cf2e7ec19d5e51657c3bbc285b181c694a9a7 /src
parent8bdb0b235afda5360699f6e786b31bf02580e4a9 (diff)
downloadgo-91aa2f190aa07addb964afa48f98466bdb1a8556.tar.gz
go-91aa2f190aa07addb964afa48f98466bdb1a8556.zip
[release-branch.go1.17] cmd/link: disable weak reference in itab if build with "-linkshared"
When build with "-linkshared", we can't tell if the interface method will be used or not. It can be used in shared library. This CL backport this fix to 1.17. Fixes #49086 Change-Id: Iba12812f199b7679cf2fd41a304268d6d6dd03c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/350189 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Alexander Rakoczy <alex@golang.org> (cherry picked from commit f687831e4cfa06d19533d47ae93c0451bd1ca688) Reviewed-on: https://go-review.googlesource.com/c/go/+/357231 Trust: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/link/internal/ld/deadcode.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go
index 416e5da398..e4fa75f8e1 100644
--- a/src/cmd/link/internal/ld/deadcode.go
+++ b/src/cmd/link/internal/ld/deadcode.go
@@ -132,7 +132,9 @@ func (d *deadcodePass) flood() {
methods = methods[:0]
for i := 0; i < relocs.Count(); i++ {
r := relocs.At(i)
- if r.Weak() {
+ // When build with "-linkshared", we can't tell if the interface
+ // method in itab will be used or not. Ignore the weak attribute.
+ if r.Weak() && !(d.ctxt.linkShared && d.ldr.IsItab(symIdx)) {
continue
}
t := r.Type()