aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/objw
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-11-08 15:18:35 -0500
committerCherry Zhang <cherryyz@google.com>2021-03-24 14:38:53 +0000
commite8700f1ce6f4103207f470cce443f04377baa600 (patch)
tree9f9bb1d99a7209b6f1500ca2e688d4765fb248ec /src/cmd/compile/internal/objw
parent747f426944b1c0c3a26537ef78cb6c5bd4d05cde (diff)
downloadgo-e8700f1ce6f4103207f470cce443f04377baa600.tar.gz
go-e8700f1ce6f4103207f470cce443f04377baa600.zip
cmd/compile, cmd/link: use weak reference in itab
When converting a type T to a non-empty interface I, we build the itab which contains the code pointers of the methods. Currently, this brings those methods live (if the itab is live), even if the interface method is never used. This CL changes the itab to use weak references, so the methods can be pruned if not otherwise live. Fixes #42421. Change-Id: Iee5de2ba11d603c5a102a2ba60440d839a7f9702 Reviewed-on: https://go-review.googlesource.com/c/go/+/268479 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/compile/internal/objw')
-rw-r--r--src/cmd/compile/internal/objw/objw.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/objw/objw.go b/src/cmd/compile/internal/objw/objw.go
index 50ce7b747d..ed5ad754d9 100644
--- a/src/cmd/compile/internal/objw/objw.go
+++ b/src/cmd/compile/internal/objw/objw.go
@@ -46,6 +46,13 @@ func SymPtr(s *obj.LSym, off int, x *obj.LSym, xoff int) int {
return off
}
+func SymPtrWeak(s *obj.LSym, off int, x *obj.LSym, xoff int) int {
+ off = int(types.Rnd(int64(off), int64(types.PtrSize)))
+ s.WriteWeakAddr(base.Ctxt, int64(off), types.PtrSize, x, int64(xoff))
+ off += types.PtrSize
+ return off
+}
+
func SymPtrOff(s *obj.LSym, off int, x *obj.LSym) int {
s.WriteOff(base.Ctxt, int64(off), x, 0)
off += 4