This source file includes following definitions.
- decode_reloc
- decode_reloc_sym
- decode_inuxi
- commonsize
- decodetype_kind
- decodetype_size
- decodetype_gc
- decodetype_arrayelem
- decodetype_arraylen
- decodetype_ptrelem
- decodetype_mapkey
- decodetype_mapvalue
- decodetype_chanelem
- decodetype_funcdotdotdot
- decodetype_funcincount
- decodetype_funcoutcount
- decodetype_funcintype
- decodetype_funcouttype
- decodetype_structfieldcount
- structfieldsize
- decodetype_structfieldname
- decodetype_structfieldtype
- decodetype_structfieldoffs
- decodetype_ifacemethodcount
#include "l.h"
#include "lib.h"
#include "../../pkg/runtime/typekind.h"
static Reloc*
decode_reloc(LSym *s, int32 off)
{
int i;
for (i = 0; i < s->nr; i++)
if (s->r[i].off == off)
return s->r + i;
return nil;
}
static LSym*
decode_reloc_sym(LSym *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)
{
uint64 v;
uint32 l;
uchar *cast, *inuxi;
int i;
v = l = 0;
cast = nil;
inuxi = nil;
switch (sz) {
case 2:
cast = (uchar*)&l;
inuxi = inuxi2;
break;
case 4:
cast = (uchar*)&l;
inuxi = inuxi4;
break;
case 8:
cast = (uchar*)&v;
inuxi = inuxi8;
break;
default:
diag("dwarf: decode inuxi %d", sz);
errorexit();
}
for (i = 0; i < sz; i++)
cast[inuxi[i]] = p[i];
if (sz == 8)
return v;
return l;
}
static int
commonsize(void)
{
return 7*PtrSize + 8;
}
uint8
decodetype_kind(LSym *s)
{
return s->p[1*PtrSize + 7] & ~KindNoPointers;
}
vlong
decodetype_size(LSym *s)
{
return decode_inuxi(s->p, PtrSize);
}
LSym*
decodetype_gc(LSym *s)
{
return decode_reloc_sym(s, 1*PtrSize + 8 + 1*PtrSize);
}
LSym*
decodetype_arrayelem(LSym *s)
{
return decode_reloc_sym(s, commonsize());
}
vlong
decodetype_arraylen(LSym *s)
{
return decode_inuxi(s->p + commonsize()+PtrSize, PtrSize);
}
LSym*
decodetype_ptrelem(LSym *s)
{
return decode_reloc_sym(s, commonsize());
}
LSym*
decodetype_mapkey(LSym *s)
{
return decode_reloc_sym(s, commonsize());
}
LSym*
decodetype_mapvalue(LSym *s)
{
return decode_reloc_sym(s, commonsize()+PtrSize);
}
LSym*
decodetype_chanelem(LSym *s)
{
return decode_reloc_sym(s, commonsize());
}
int
decodetype_funcdotdotdot(LSym *s)
{
return s->p[commonsize()];
}
int
decodetype_funcincount(LSym *s)
{
return decode_inuxi(s->p + commonsize()+2*PtrSize, IntSize);
}
int
decodetype_funcoutcount(LSym *s)
{
return decode_inuxi(s->p + commonsize()+3*PtrSize + 2*IntSize, IntSize);
}
LSym*
decodetype_funcintype(LSym *s, int i)
{
Reloc *r;
r = decode_reloc(s, commonsize() + PtrSize);
if (r == nil)
return nil;
return decode_reloc_sym(r->sym, r->add + i * PtrSize);
}
LSym*
decodetype_funcouttype(LSym *s, int i)
{
Reloc *r;
r = decode_reloc(s, commonsize() + 2*PtrSize + 2*IntSize);
if (r == nil)
return nil;
return decode_reloc_sym(r->sym, r->add + i * PtrSize);
}
int
decodetype_structfieldcount(LSym *s)
{
return decode_inuxi(s->p + commonsize() + PtrSize, IntSize);
}
static int
structfieldsize(void)
{
return 5*PtrSize;
}
char*
decodetype_structfieldname(LSym *s, int i)
{
Reloc *r;
s = decode_reloc_sym(s, commonsize() + PtrSize + 2*IntSize + i*structfieldsize());
if (s == nil)
return nil;
r = decode_reloc(s, 0);
if (r == nil)
return nil;
return (char*) r->sym->p + r->add;
}
LSym*
decodetype_structfieldtype(LSym *s, int i)
{
return decode_reloc_sym(s, commonsize() + PtrSize + 2*IntSize + i*structfieldsize() + 2*PtrSize);
}
vlong
decodetype_structfieldoffs(LSym *s, int i)
{
return decode_inuxi(s->p + commonsize() + PtrSize + 2*IntSize + i*structfieldsize() + 4*PtrSize, IntSize);
}
vlong
decodetype_ifacemethodcount(LSym *s)
{
return decode_inuxi(s->p + commonsize() + PtrSize, IntSize);
}