aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ld/dwarf.c
diff options
context:
space:
mode:
authorLuuk van Dijk <lvd@golang.org>2011-01-24 20:59:39 +0100
committerLuuk van Dijk <lvd@golang.org>2011-01-24 20:59:39 +0100
commit2aa6cf3e7ec578d7fb4d4a2aa73e4685fb5df1de (patch)
tree96062b1cfe89bf9d38b7c60ab06f6df527eb8af6 /src/cmd/ld/dwarf.c
parent59a6395279e8529b54d96bb84051d38206d63e50 (diff)
downloadgo-2aa6cf3e7ec578d7fb4d4a2aa73e4685fb5df1de.tar.xz
[68]l: more robust decoding of reflection type info in generating dwarf.
R=rsc CC=golang-dev, golang-dev https://golang.org/cl/4106041
Diffstat (limited to 'src/cmd/ld/dwarf.c')
-rw-r--r--src/cmd/ld/dwarf.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/cmd/ld/dwarf.c b/src/cmd/ld/dwarf.c
index b724a98f5d..62f339d6dd 100644
--- a/src/cmd/ld/dwarf.c
+++ b/src/cmd/ld/dwarf.c
@@ -798,6 +798,17 @@ decode_reloc(Sym *s, int32 off)
return nil;
}
+static Sym*
+decode_reloc_sym(Sym *s, int32 off)
+{
+ Reloc *r;
+
+ r = decode_reloc(s,off);
+ if (r == nil)
+ return nil;
+ return r->sym;
+}
+
static uvlong
decode_inuxi(uchar* p, int sz)
{
@@ -851,7 +862,7 @@ decodetype_size(Sym *s)
static Sym*
decodetype_arrayelem(Sym *s)
{
- return decode_reloc(s, 5*PtrSize + 8)->sym; // 0x1c / 0x30
+ return decode_reloc_sym(s, 5*PtrSize + 8); // 0x1c / 0x30
}
static vlong
@@ -864,26 +875,26 @@ decodetype_arraylen(Sym *s)
static Sym*
decodetype_ptrelem(Sym *s)
{
- return decode_reloc(s, 5*PtrSize + 8)->sym; // 0x1c / 0x30
+ return decode_reloc_sym(s, 5*PtrSize + 8); // 0x1c / 0x30
}
// Type.MapType.key, elem
static Sym*
decodetype_mapkey(Sym *s)
{
- return decode_reloc(s, 5*PtrSize + 8)->sym; // 0x1c / 0x30
+ return decode_reloc_sym(s, 5*PtrSize + 8); // 0x1c / 0x30
}
static Sym*
decodetype_mapvalue(Sym *s)
{
- return decode_reloc(s, 6*PtrSize + 8)->sym; // 0x20 / 0x38
+ return decode_reloc_sym(s, 6*PtrSize + 8); // 0x20 / 0x38
}
// Type.ChanType.elem
static Sym*
decodetype_chanelem(Sym *s)
{
- return decode_reloc(s, 5*PtrSize + 8)->sym; // 0x1c / 0x30
+ return decode_reloc_sym(s, 5*PtrSize + 8); // 0x1c / 0x30
}
// Type.FuncType.dotdotdot
@@ -912,7 +923,9 @@ decodetype_funcintype(Sym *s, int i)
Reloc *r;
r = decode_reloc(s, 6*PtrSize + 8);
- return decode_reloc(r->sym, r->add + i * PtrSize)->sym;
+ if (r == nil)
+ return nil;
+ return decode_reloc_sym(r->sym, r->add + i * PtrSize);
}
static Sym*
@@ -921,7 +934,9 @@ decodetype_funcouttype(Sym *s, int i)
Reloc *r;
r = decode_reloc(s, 7*PtrSize + 16);
- return decode_reloc(r->sym, r->add + i * PtrSize)->sym;
+ if (r == nil)
+ return nil;
+ return decode_reloc_sym(r->sym, r->add + i * PtrSize);
}
// Type.StructType.fields.Slice::len
@@ -935,21 +950,20 @@ decodetype_structfieldcount(Sym *s)
static char*
decodetype_structfieldname(Sym *s, int i)
{
- Reloc* r;
-
- r = decode_reloc(s, 6*PtrSize + 0x10 + i*5*PtrSize); // go.string."foo" 0x28 / 0x40
- if (r == nil) // embedded structs have a nil name.
+ // go.string."foo" 0x28 / 0x40
+ s = decode_reloc_sym(s, 6*PtrSize + 0x10 + i*5*PtrSize);
+ if (s == nil) // embedded structs have a nil name.
return nil;
- r = decode_reloc(r->sym, 0); // string."foo"
- if (r == nil) // shouldn't happen.
+ s = decode_reloc_sym(s, 0); // string."foo"
+ if (s == nil) // shouldn't happen.
return nil;
- return (char*)r->sym->p; // the c-string
+ return (char*)s->p; // the c-string
}
static Sym*
decodetype_structfieldtype(Sym *s, int i)
{
- return decode_reloc(s, 8*PtrSize + 0x10 + i*5*PtrSize)->sym; // 0x30 / 0x50
+ return decode_reloc_sym(s, 8*PtrSize + 0x10 + i*5*PtrSize); // 0x30 / 0x50
}
static vlong