From e8700f1ce6f4103207f470cce443f04377baa600 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Sun, 8 Nov 2020 15:18:35 -0500 Subject: 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 Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- src/cmd/compile/internal/reflectdata/reflect.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd/compile/internal/reflectdata/reflect.go') diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 0e1de35887..4c974ea324 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -1338,7 +1338,7 @@ func WriteTabs() { o = objw.Uint32(i.lsym, o, types.TypeHash(i.t)) // copy of type hash o += 4 // skip unused field for _, fn := range genfun(i.t, i.itype) { - o = objw.SymPtr(i.lsym, o, fn, 0) // method pointer for each method + o = objw.SymPtrWeak(i.lsym, o, fn, 0) // method pointer for each method } // Nothing writes static itabs, so they are read only. objw.Global(i.lsym, int32(o), int16(obj.DUPOK|obj.RODATA)) -- cgit v1.2.3-54-g00ecf