aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/data.go
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/internal/obj/data.go
parent747f426944b1c0c3a26537ef78cb6c5bd4d05cde (diff)
downloadgo-e8700f1ce6f4103207f470cce443f04377baa600.tar.xz
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/internal/obj/data.go')
-rw-r--r--src/cmd/internal/obj/data.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/internal/obj/data.go b/src/cmd/internal/obj/data.go
index f32e07acfe..bcba53c3a4 100644
--- a/src/cmd/internal/obj/data.go
+++ b/src/cmd/internal/obj/data.go
@@ -135,6 +135,13 @@ func (s *LSym) WriteAddr(ctxt *Link, off int64, siz int, rsym *LSym, roff int64)
s.writeAddr(ctxt, off, siz, rsym, roff, objabi.R_ADDR)
}
+// WriteWeakAddr writes an address of size siz into s at offset off.
+// rsym and roff specify the relocation for the address.
+// This is a weak reference.
+func (s *LSym) WriteWeakAddr(ctxt *Link, off int64, siz int, rsym *LSym, roff int64) {
+ s.writeAddr(ctxt, off, siz, rsym, roff, objabi.R_WEAKADDR)
+}
+
// WriteCURelativeAddr writes a pointer-sized address into s at offset off.
// rsym and roff specify the relocation for the address which will be
// resolved by the linker to an offset from the DW_AT_low_pc attribute of