Commit c7c16175 authored by Russ Cox's avatar Russ Cox

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
parent cc1556d9
...@@ -1834,6 +1834,8 @@ writelines(void) ...@@ -1834,6 +1834,8 @@ writelines(void)
for(cursym = textp; cursym != nil; cursym = cursym->next) { for(cursym = textp; cursym != nil; cursym = cursym->next) {
s = cursym; s = cursym;
if(s->text == P)
continue;
// Look for history stack. If we find one, // Look for history stack. If we find one,
// we're entering a new compilation unit // we're entering a new compilation unit
......
...@@ -484,7 +484,7 @@ ldelf(Biobuf *f, char *pkg, int64 len, char *pn) ...@@ -484,7 +484,7 @@ ldelf(Biobuf *f, char *pkg, int64 len, char *pn)
// load string table for symbols into memory. // load string table for symbols into memory.
obj->symtab = section(obj, ".symtab"); obj->symtab = section(obj, ".symtab");
if(obj->symtab == nil) { 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; return;
} }
if(obj->symtab->link <= 0 || obj->symtab->link >= obj->nsect) { if(obj->symtab->link <= 0 || obj->symtab->link >= obj->nsect) {
......
...@@ -541,8 +541,8 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn) ...@@ -541,8 +541,8 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn)
goto bad; goto bad;
} }
if(symtab == nil) { if(symtab == nil) {
werrstr("no symbol table"); // our work is done here - no symbols means nothing can refer to this file
goto bad; return;
} }
if(c->seg.fileoff+c->seg.filesz >= len) { if(c->seg.fileoff+c->seg.filesz >= len) {
...@@ -652,7 +652,6 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn) ...@@ -652,7 +652,6 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn)
sym->sym = s; sym->sym = s;
} }
// load relocations // load relocations
for(i=0; i<c->seg.nsect; i++) { for(i=0; i<c->seg.nsect; i++) {
sect = &c->seg.sect[i]; sect = &c->seg.sect[i];
......
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