1
0
mirror of https://github.com/golang/go synced 2024-11-20 05:14:41 -07:00

cmd/ld: prepare for 64-bit ints

Use explicit IntSize constant instead of 4.

This CL does not change the meaning of int, but it should make
the eventual change of the meaning of int on amd64 a bit
smoother.

Update #2188.

R=ken, dave
CC=golang-dev
https://golang.org/cl/6554076
This commit is contained in:
Russ Cox 2012-09-24 14:59:09 -04:00
parent 5501a097a9
commit 0bf46d0cf3
4 changed files with 11 additions and 8 deletions

View File

@ -37,6 +37,7 @@ enum
{
thechar = '5',
PtrSize = 4,
IntSize = 4,
FuncAlign = 4 // single-instruction alignment
};

View File

@ -41,6 +41,7 @@ enum
{
thechar = '6',
PtrSize = 8,
IntSize = 4,
// Loop alignment constants:
// want to align loop entry to LoopAlign-byte boundary,

View File

@ -41,6 +41,7 @@ enum
{
thechar = '8',
PtrSize = 4,
IntSize = 4,
FuncAlign = 16
};

View File

@ -138,13 +138,13 @@ decodetype_funcdotdotdot(Sym *s)
int
decodetype_funcincount(Sym *s)
{
return decode_inuxi(s->p + CommonSize+2*PtrSize, 4);
return decode_inuxi(s->p + CommonSize+2*PtrSize, IntSize);
}
int
decodetype_funcoutcount(Sym *s)
{
return decode_inuxi(s->p + CommonSize+3*PtrSize + 2*4, 4);
return decode_inuxi(s->p + CommonSize+3*PtrSize + 2*IntSize, IntSize);
}
Sym*
@ -163,7 +163,7 @@ decodetype_funcouttype(Sym *s, int i)
{
Reloc *r;
r = decode_reloc(s, CommonSize + 2*PtrSize + 2*4);
r = decode_reloc(s, CommonSize + 2*PtrSize + 2*IntSize);
if (r == nil)
return nil;
return decode_reloc_sym(r->sym, r->add + i * PtrSize);
@ -173,7 +173,7 @@ decodetype_funcouttype(Sym *s, int i)
int
decodetype_structfieldcount(Sym *s)
{
return decode_inuxi(s->p + CommonSize + PtrSize, 4);
return decode_inuxi(s->p + CommonSize + PtrSize, IntSize);
}
enum {
@ -186,7 +186,7 @@ decodetype_structfieldname(Sym *s, int i)
Reloc *r;
// go.string."foo" 0x28 / 0x40
s = decode_reloc_sym(s, CommonSize + PtrSize + 2*4 + i*StructFieldSize);
s = decode_reloc_sym(s, CommonSize + PtrSize + 2*IntSize + i*StructFieldSize);
if (s == nil) // embedded structs have a nil name.
return nil;
r = decode_reloc(s, 0); // s has a pointer to the string data at offset 0
@ -198,18 +198,18 @@ decodetype_structfieldname(Sym *s, int i)
Sym*
decodetype_structfieldtype(Sym *s, int i)
{
return decode_reloc_sym(s, CommonSize + PtrSize + 2*4 + i*StructFieldSize + 2*PtrSize);
return decode_reloc_sym(s, CommonSize + PtrSize + 2*IntSize + i*StructFieldSize + 2*PtrSize);
}
vlong
decodetype_structfieldoffs(Sym *s, int i)
{
return decode_inuxi(s->p + CommonSize + PtrSize + 2*4 + i*StructFieldSize + 4*PtrSize, 4);
return decode_inuxi(s->p + CommonSize + PtrSize + 2*IntSize + i*StructFieldSize + 4*PtrSize, IntSize);
}
// InterfaceTYpe.methods.len
vlong
decodetype_ifacemethodcount(Sym *s)
{
return decode_inuxi(s->p + CommonSize + PtrSize, 4);
return decode_inuxi(s->p + CommonSize + PtrSize, IntSize);
}