From 109c7bbf8f4d78896e383db08c33d5ae91f7a86b Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 12 Dec 2023 21:25:14 -0800 Subject: [PATCH] cmd/link: use symbolic offset for ITab.Type Change-Id: If04c24d5209cd241e300ce714efdd0e0dde61af2 Reviewed-on: https://go-review.googlesource.com/c/go/+/549456 Reviewed-by: David Chase Reviewed-by: Than McIntosh LUCI-TryBot-Result: Go LUCI --- src/cmd/compile/internal/rttype/rttype.go | 3 +++ src/cmd/link/internal/ld/decodesym.go | 2 +- src/internal/abi/compiletype.go | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/rttype/rttype.go b/src/cmd/compile/internal/rttype/rttype.go index b53ed8001f..b90e23dc5b 100644 --- a/src/cmd/compile/internal/rttype/rttype.go +++ b/src/cmd/compile/internal/rttype/rttype.go @@ -85,6 +85,9 @@ func Init() { if got, want := int64(abi.TFlagOff(ptrSize)), Type.OffsetOf("TFlag"); got != want { base.Fatalf("abi.TFlagOff() == %d, want %d", got, want) } + if got, want := int64(abi.ITabTypeOff(ptrSize)), ITab.OffsetOf("Type"); got != want { + base.Fatalf("abi.ITabTypeOff() == %d, want %d", got, want) + } } // fromReflect translates from a host type to the equivalent target type. diff --git a/src/cmd/link/internal/ld/decodesym.go b/src/cmd/link/internal/ld/decodesym.go index b66f227549..aa40496492 100644 --- a/src/cmd/link/internal/ld/decodesym.go +++ b/src/cmd/link/internal/ld/decodesym.go @@ -304,5 +304,5 @@ func decodetypeGcprogShlib(ctxt *Link, data []byte) uint64 { // decodeItabType returns the itab.Type field from an itab. func decodeItabType(ldr *loader.Loader, arch *sys.Arch, symIdx loader.Sym) loader.Sym { relocs := ldr.Relocs(symIdx) - return decodeRelocSym(ldr, symIdx, &relocs, int32(arch.PtrSize)) + return decodeRelocSym(ldr, symIdx, &relocs, int32(abi.ITabTypeOff(arch.PtrSize))) } diff --git a/src/internal/abi/compiletype.go b/src/internal/abi/compiletype.go index 6f1a2d672c..f00a69c7cd 100644 --- a/src/internal/abi/compiletype.go +++ b/src/internal/abi/compiletype.go @@ -23,3 +23,6 @@ func UncommonSize() uint64 { return 4 + 2 + 2 + 4 + 4 } // TFlagOff returns the offset of Type.TFlag for a compilation target with a given ptrSize func TFlagOff(ptrSize int) int { return 2*ptrSize + 4 } + +// ITabTypeOff returns the offset of ITab.Type for a compilation target with a given ptrSize +func ITabTypeOff(ptrSize int) int { return ptrSize } -- 2.48.1