]> Cypherpunks repositories - gostls13.git/commitdiff
ld: allow .o files with no symbols
authorRuss Cox <rsc@golang.org>
Mon, 13 Dec 2010 15:05:07 +0000 (10:05 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 13 Dec 2010 15:05:07 +0000 (10:05 -0500)
Don't crash in dwarf for foreign functions.

R=ken2
CC=golang-dev
https://golang.org/cl/3576043

src/cmd/ld/dwarf.c
src/cmd/ld/ldelf.c
src/cmd/ld/ldmacho.c

index 706307840688a382810e9e1627817428dec606eb..21e079a65c58e5dbb4589a5d788719b358b33a2e 100644 (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
index feda761394bcab9884e07d7dfe7491aeafcffc82..f3dd8636b67ad98b3a05fd0b014e6671f93a421b 100644 (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) {
index 78c868e340aeeb04db87daf1a1e8c897feafe1ce..ba243245bfe3469717af6daaabe0a22b7b3258d6 100644 (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++) {