]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: use symbolic offset for ITab.Type
authorKeith Randall <khr@golang.org>
Wed, 13 Dec 2023 05:25:14 +0000 (21:25 -0800)
committerKeith Randall <khr@golang.org>
Thu, 8 Feb 2024 03:01:24 +0000 (03:01 +0000)
Change-Id: If04c24d5209cd241e300ce714efdd0e0dde61af2
Reviewed-on: https://go-review.googlesource.com/c/go/+/549456
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/rttype/rttype.go
src/cmd/link/internal/ld/decodesym.go
src/internal/abi/compiletype.go

index b53ed8001f08f7257b2125b1b56e78d8923770e5..b90e23dc5b4cfd6fae41d420de3e958a77db3a2c 100644 (file)
@@ -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.
index b66f227549ed93e3dd18c57e87884293539abdb8..aa404964928d2c27c67e0bff9bb9d3f3680bdad8 100644 (file)
@@ -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)))
 }
index 6f1a2d672c430f9f4e3a073d941294d2204f0200..f00a69c7cd91c75298557de5b0119b790a197502 100644 (file)
@@ -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 }