aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-12-13 10:05:07 -0500
committerRuss Cox <rsc@golang.org>2010-12-13 10:05:07 -0500
commitc7c16175e028fdd3e03ff1aea41cbc965428d19e (patch)
tree1ebec572e470569bad9b94d0dbac14d863d2e41a
parentcc1556d9a29865f1cce8d0ee516b6116bae3ca54 (diff)
downloadgo-c7c16175e028fdd3e03ff1aea41cbc965428d19e.tar.gz
go-c7c16175e028fdd3e03ff1aea41cbc965428d19e.zip
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
-rw-r--r--src/cmd/ld/dwarf.c2
-rw-r--r--src/cmd/ld/ldelf.c2
-rw-r--r--src/cmd/ld/ldmacho.c5
3 files changed, 5 insertions, 4 deletions
diff --git a/src/cmd/ld/dwarf.c b/src/cmd/ld/dwarf.c
index 7063078406..21e079a65c 100644
--- a/src/cmd/ld/dwarf.c
+++ b/src/cmd/ld/dwarf.c
@@ -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
diff --git a/src/cmd/ld/ldelf.c b/src/cmd/ld/ldelf.c
index feda761394..f3dd8636b6 100644
--- a/src/cmd/ld/ldelf.c
+++ b/src/cmd/ld/ldelf.c
@@ -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) {
diff --git a/src/cmd/ld/ldmacho.c b/src/cmd/ld/ldmacho.c
index 78c868e340..ba243245bf 100644
--- a/src/cmd/ld/ldmacho.c
+++ b/src/cmd/ld/ldmacho.c
@@ -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++) {