Commit 0bf46d0c authored by Russ Cox's avatar Russ Cox

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
parent 5501a097
...@@ -37,6 +37,7 @@ enum ...@@ -37,6 +37,7 @@ enum
{ {
thechar = '5', thechar = '5',
PtrSize = 4, PtrSize = 4,
IntSize = 4,
FuncAlign = 4 // single-instruction alignment FuncAlign = 4 // single-instruction alignment
}; };
......
...@@ -41,6 +41,7 @@ enum ...@@ -41,6 +41,7 @@ enum
{ {
thechar = '6', thechar = '6',
PtrSize = 8, PtrSize = 8,
IntSize = 4,
// Loop alignment constants: // Loop alignment constants:
// want to align loop entry to LoopAlign-byte boundary, // want to align loop entry to LoopAlign-byte boundary,
......
...@@ -41,6 +41,7 @@ enum ...@@ -41,6 +41,7 @@ enum
{ {
thechar = '8', thechar = '8',
PtrSize = 4, PtrSize = 4,
IntSize = 4,
FuncAlign = 16 FuncAlign = 16
}; };
......
...@@ -138,13 +138,13 @@ decodetype_funcdotdotdot(Sym *s) ...@@ -138,13 +138,13 @@ decodetype_funcdotdotdot(Sym *s)
int int
decodetype_funcincount(Sym *s) decodetype_funcincount(Sym *s)
{ {
return decode_inuxi(s->p + CommonSize+2*PtrSize, 4); return decode_inuxi(s->p + CommonSize+2*PtrSize, IntSize);
} }
int int
decodetype_funcoutcount(Sym *s) 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* Sym*
...@@ -163,7 +163,7 @@ decodetype_funcouttype(Sym *s, int i) ...@@ -163,7 +163,7 @@ decodetype_funcouttype(Sym *s, int i)
{ {
Reloc *r; Reloc *r;
r = decode_reloc(s, CommonSize + 2*PtrSize + 2*4); r = decode_reloc(s, CommonSize + 2*PtrSize + 2*IntSize);
if (r == nil) if (r == nil)
return nil; return nil;
return decode_reloc_sym(r->sym, r->add + i * PtrSize); return decode_reloc_sym(r->sym, r->add + i * PtrSize);
...@@ -173,7 +173,7 @@ decodetype_funcouttype(Sym *s, int i) ...@@ -173,7 +173,7 @@ decodetype_funcouttype(Sym *s, int i)
int int
decodetype_structfieldcount(Sym *s) decodetype_structfieldcount(Sym *s)
{ {
return decode_inuxi(s->p + CommonSize + PtrSize, 4); return decode_inuxi(s->p + CommonSize + PtrSize, IntSize);
} }
enum { enum {
...@@ -186,7 +186,7 @@ decodetype_structfieldname(Sym *s, int i) ...@@ -186,7 +186,7 @@ decodetype_structfieldname(Sym *s, int i)
Reloc *r; Reloc *r;
// go.string."foo" 0x28 / 0x40 // 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. if (s == nil) // embedded structs have a nil name.
return nil; return nil;
r = decode_reloc(s, 0); // s has a pointer to the string data at offset 0 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) ...@@ -198,18 +198,18 @@ decodetype_structfieldname(Sym *s, int i)
Sym* Sym*
decodetype_structfieldtype(Sym *s, int i) 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 vlong
decodetype_structfieldoffs(Sym *s, int i) 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 // InterfaceTYpe.methods.len
vlong vlong
decodetype_ifacemethodcount(Sym *s) decodetype_ifacemethodcount(Sym *s)
{ {
return decode_inuxi(s->p + CommonSize + PtrSize, 4); return decode_inuxi(s->p + CommonSize + PtrSize, IntSize);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment