MAXELEMSIZE = abi.MapMaxElemBytes
)
-func structfieldSize() int { return 3 * types.PtrSize } // Sizeof(runtime.structfield{})
-func imethodSize() int { return 4 + 4 } // Sizeof(runtime.imethod{})
-func commonSize() int { return 4*types.PtrSize + 8 + 8 } // Sizeof(runtime._type{})
+func structfieldSize() int { return abi.StructFieldSize(types.PtrSize) } // Sizeof(runtime.structfield{})
+func imethodSize() int { return abi.IMethodSize(types.PtrSize) } // Sizeof(runtime.imethod{})
+func commonSize() int { return abi.CommonSize(types.PtrSize) } // Sizeof(runtime._type{})
func uncommonSize(t *types.Type) int { // Sizeof(runtime.uncommontype{})
if t.Sym() == nil && len(methods(t)) == 0 {
return 0
}
- return 4 + 2 + 2 + 4 + 4
+ return int(abi.UncommonSize())
}
func makefield(name string, t *types.Type) *types.Field {
base.Fatalf("unsupported map key type for %v", t)
}
if BUCKETSIZE < 8 {
- base.Fatalf("bucket size too small for proper alignment")
+ base.Fatalf("bucket size %d too small for proper alignment %d", BUCKETSIZE, 8)
}
if uint8(keytype.Alignment()) > BUCKETSIZE {
base.Fatalf("key align too big for %v", t)
}
if uint8(elemtype.Alignment()) > BUCKETSIZE {
- base.Fatalf("elem align too big for %v", t)
+ base.Fatalf("elem align %d too big for %v, BUCKETSIZE=%d", elemtype.Alignment(), t, BUCKETSIZE)
}
if keytype.Size() > MAXKEYSIZE {
base.Fatalf("key size to large for %v", t)
// Double-check that overflow field is final memory in struct,
// with no padding at end.
if overflow.Offset != bucket.Size()-int64(types.PtrSize) {
- base.Fatalf("bad offset of overflow in bmap for %v", t)
+ base.Fatalf("bad offset of overflow in bmap for %v, overflow.Offset=%d, bucket.Size()-int64(types.PtrSize)=%d",
+ t, overflow.Offset, bucket.Size()-int64(types.PtrSize))
}
t.MapType().Bucket = bucket
}
}
-func commonsize(arch *sys.Arch) int { return 4*arch.PtrSize + 8 + 8 } // runtime._type
-func structfieldSize(arch *sys.Arch) int { return 3 * arch.PtrSize } // runtime.structfield
-func uncommonSize() int { return 4 + 2 + 2 + 4 + 4 } // runtime.uncommontype
+func commonsize(arch *sys.Arch) int { return abi.CommonSize(arch.PtrSize) } // runtime._type
+func structfieldSize(arch *sys.Arch) int { return abi.StructFieldSize(arch.PtrSize) } // runtime.structfield
+func uncommonSize(arch *sys.Arch) int { return int(abi.UncommonSize()) } // runtime.uncommontype
// Type.commonType.kind
func decodetypeKind(arch *sys.Arch, p []byte) uint8 {
uadd += 4
}
if decodetypeHasUncommon(arch, ldr.Data(symIdx)) {
- uadd += uncommonSize()
+ uadd += uncommonSize(arch)
}
return decodeRelocSym(ldr, symIdx, relocs, int32(uadd+i*arch.PtrSize))
}
data := ldr.Data(symIdx)
off := commonsize(arch) + 4*arch.PtrSize
if decodetypeHasUncommon(arch, data) {
- off += uncommonSize()
+ off += uncommonSize(arch)
}
off += i * structfieldSize(arch)
return off