Commit 0cc055e8 authored by Luuk van Dijk's avatar Luuk van Dijk Committed by Russ Cox

ld: fix dwarf decoding of strings for struct's fieldnames

Moved Sym printing to Yconv.
Fixed warning in data.c

R=rsc
CC=golang-dev
https://golang.org/cl/4378052
parent d36271a3
......@@ -722,7 +722,7 @@ addsize(Sym *s, Sym *t)
void
dodata(void)
{
int32 h, t, datsize;
int32 t, datsize;
Section *sect;
Sym *s, *last, **l;
......
......@@ -6,7 +6,6 @@
// - eliminate DW_CLS_ if not used
// - package info in compilation units
// - assign global variables and types to their packages
// - (upstream) type info for C parts of runtime
// - gdb uses c syntax, meaning clumsy quoting is needed for go identifiers. eg
// ptype struct '[]uint8' and qualifiers need to be quoted away
// - lexical scoping is lost, so gdb gets confused as to which 'main.i' you mean.
......@@ -943,14 +942,16 @@ enum {
static char*
decodetype_structfieldname(Sym *s, int i)
{
Reloc *r;
// go.string."foo" 0x28 / 0x40
s = decode_reloc_sym(s, CommonSize + PtrSize + 2*4 + i*StructFieldSize);
if (s == nil) // embedded structs have a nil name.
return nil;
s = decode_reloc_sym(s, 0); // string."foo"
if (s == nil) // shouldn't happen.
r = decode_reloc(s, 0); // s has a pointer to the string data at offset 0
if (r == nil) // shouldn't happen.
return nil;
return (char*)s->p; // the c-string
return (char*) r->sym->p + r->add; // the c-string
}
static Sym*
......@@ -1021,22 +1022,8 @@ defgotype(Sym *gotype)
if (die != nil)
return die;
if (0 && debug['v'] > 2) {
print("new type: %s @0x%08x [%d]", gotype->name, gotype->value, gotype->size);
for (i = 0; i < gotype->size; i++) {
if (!(i%8)) print("\n\t%04x ", i);
print("%02x ", gotype->p[i]);
}
print("\n");
for (i = 0; i < gotype->nr; i++) {
print("\t0x%02x[%x] %d %s[%llx]\n",
gotype->r[i].off,
gotype->r[i].siz,
gotype->r[i].type,
gotype->r[i].sym->name,
(vlong)gotype->r[i].add);
}
}
if (0 && debug['v'] > 2)
print("new type: %Y\n", gotype);
kind = decodetype_kind(gotype);
bytesize = decodetype_size(gotype);
......@@ -2321,7 +2308,7 @@ dwarfemitdebugsections(void)
{
vlong infoe;
DWDie* die;
return;
// For diagnostic messages.
newattr(&dwtypes, DW_AT_name, DW_CLS_STRING, strlen("dwtypes"), "dwtypes");
......
......@@ -61,6 +61,7 @@ void
libinit(void)
{
fmtinstall('i', iconv);
fmtinstall('Y', Yconv);
mywhatsys(); // get goroot, goarch, goos
if(strcmp(goarch, thestring) != 0)
print("goarch is not known: %s\n", goarch);
......@@ -847,7 +848,7 @@ unmal(void *v, uint32 n)
// Copied from ../gc/subr.c:/^pathtoprefix; must stay in sync.
/*
* Convert raw string to the prefix that will be used in the symbol table.
* Invalid bytes turn into %xx. Right now the only bytes that need
* Invalid bytes turn into %xx. Right now the only bytes that need
* escaping are %, ., and ", but we escape all control characters too.
*/
static char*
......@@ -1122,7 +1123,7 @@ static Sym *newstack;
enum
{
HasLinkRegister = (thechar == '5'),
CallSize = (!HasLinkRegister)*PtrSize, // bytes of stack required for a call
CallSize = (!HasLinkRegister)*PtrSize, // bytes of stack required for a call
};
void
......@@ -1148,7 +1149,7 @@ dostkcheck(void)
// Check calling contexts.
// Some nosplits get called a little further down,
// like newproc and deferproc. We could hard-code
// like newproc and deferproc. We could hard-code
// that knowledge but it's more robust to look at
// the actual call sites.
for(s = textp; s != nil; s = s->next) {
......@@ -1307,3 +1308,38 @@ undef(void)
if(s->type == SXREF)
diag("%s(%d): not defined", s->name, s->version);
}
int
Yconv(Fmt *fp)
{
Sym *s;
Fmt fmt;
int i;
char *str;
s = va_arg(fp->args, Sym*);
if (s == S) {
fmtprint(fp, "<nil>");
} else {
fmtstrinit(&fmt);
fmtprint(&fmt, "%s @0x%08x [%d]", s->name, s->value, s->size);
for (i = 0; i < s->size; i++) {
if (!(i%8)) fmtprint(&fmt, "\n\t0x%04x ", i);
fmtprint(&fmt, "%02x ", s->p[i]);
}
fmtprint(&fmt, "\n");
for (i = 0; i < s->nr; i++) {
fmtprint(&fmt, "\t0x%04x[%x] %d %s[%llx]\n",
s->r[i].off,
s->r[i].siz,
s->r[i].type,
s->r[i].sym->name,
(vlong)s->r[i].add);
}
str = fmtstrflush(&fmt);
fmtstrcpy(fp, str);
free(str);
}
return 0;
}
......@@ -274,3 +274,6 @@ EXTERN char* headstring;
extern Header headers[];
int headtype(char*);
int Yconv(Fmt*);
#pragma varargck type "Y" Sym*
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