]> Cypherpunks repositories - gostls13.git/commitdiff
ld: fix Mach-O bss bug
authorMikkel Krautz <mikkel@krautz.dk>
Thu, 7 Apr 2011 17:17:28 +0000 (13:17 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 7 Apr 2011 17:17:28 +0000 (13:17 -0400)
Fixes #1559.

R=rsc
CC=golang-dev, peterGo, rog
https://golang.org/cl/4356046

src/cmd/ld/data.c
src/cmd/ld/ldmacho.c

index 848c3637d3ab1416a9786c9283b280b287ee76e1..5b74971d8318fbdcda018dd6afbc84e9f070cb4d 100644 (file)
@@ -749,7 +749,7 @@ dodata(void)
        }
 
        for(s = datap; s != nil; s = s->next) {
-               if(s->np > 0 && s->type == SBSS)        // TODO: necessary?
+               if(s->np > 0 && s->type == SBSS && s->file != nil)      // TODO: necessary?
                        s->type = SDATA;
                if(s->np > s->size)
                        diag("%s: initialize bounds (%lld < %d)",
index 7e38db0e44fae9473905de8fce5cdca737a37792..fbf2f1779b5a5b86797a241b991a8e5725d2f368 100644 (file)
@@ -581,7 +581,10 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn)
                        else
                                s->type = SRODATA;
                } else {
-                       s->type = SDATA;
+                       if (strcmp(sect->name, "__bss") == 0)
+                               s->type = SBSS;
+                       else
+                               s->type = SDATA;
                }
                if(s->type == STEXT) {
                        if(etextp)