1
0
mirror of https://github.com/golang/go synced 2024-11-21 14:24:44 -07:00

ld: allow .o files with no symbols

Don't crash in dwarf for foreign functions.

R=ken2
CC=golang-dev
https://golang.org/cl/3576043
This commit is contained in:
Russ Cox 2010-12-13 10:05:07 -05:00
parent cc1556d9a2
commit c7c16175e0
3 changed files with 5 additions and 4 deletions

View File

@ -1834,6 +1834,8 @@ writelines(void)
for(cursym = textp; cursym != nil; cursym = cursym->next) {
s = cursym;
if(s->text == P)
continue;
// Look for history stack. If we find one,
// we're entering a new compilation unit

View File

@ -484,7 +484,7 @@ ldelf(Biobuf *f, char *pkg, int64 len, char *pn)
// load string table for symbols into memory.
obj->symtab = section(obj, ".symtab");
if(obj->symtab == nil) {
diag("%s: elf object has no symbol table", pn);
// our work is done here - no symbols means nothing can refer to this file
return;
}
if(obj->symtab->link <= 0 || obj->symtab->link >= obj->nsect) {

View File

@ -541,8 +541,8 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn)
goto bad;
}
if(symtab == nil) {
werrstr("no symbol table");
goto bad;
// our work is done here - no symbols means nothing can refer to this file
return;
}
if(c->seg.fileoff+c->seg.filesz >= len) {
@ -651,7 +651,6 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn)
}
sym->sym = s;
}
// load relocations
for(i=0; i<c->seg.nsect; i++) {