]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: use 64-bit alignment for large data and bss objects
authorRuss Cox <rsc@golang.org>
Tue, 9 Oct 2012 16:50:06 +0000 (12:50 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 9 Oct 2012 16:50:06 +0000 (12:50 -0400)
Check for specific, important misalignment in garbage collector.
Not a complete fix for issue 599 but an important workaround.

Update #599.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/6641049

src/cmd/ld/data.c
src/pkg/runtime/mgc0.c

index 89eccd143ccc0d03ae7a7feb80b7e0c17159a201..4afe4b801cb08c142344cc456f5ceb708bdede3e 100644 (file)
@@ -831,7 +831,9 @@ dosymtype(void)
 static int32
 alignsymsize(int32 s)
 {
-       if(s >= PtrSize)
+       if(s >= 8)
+               s = rnd(s, 8);
+       else if(s >= PtrSize)
                s = rnd(s, PtrSize);
        else if(s > 2)
                s = rnd(s, 4);
@@ -1054,6 +1056,7 @@ dodata(void)
                datsize += rnd(s->size, PtrSize);
        }
        sect->len = datsize - sect->vaddr;
+       datsize = rnd(datsize, PtrSize);
 
        /* gcdata */
        sect = addsection(&segtext, ".gcdata", 04);
index 6c2ce009538d0766003e7371028b0fe30d63635a..dc3b877c4e461327dae293f353339f8a2a439005 100644 (file)
@@ -892,6 +892,12 @@ runtime·gc(int32 force)
        M *m1;
        uint32 i;
 
+       // The atomic operations are not atomic if the uint64s
+       // are not aligned on uint64 boundaries. This has been
+       // a problem in the past.
+       if((((uintptr)&work.empty) & 7) != 0)
+               runtime·throw("runtime: gc work buffer is misaligned");
+
        // The gc is turned off (via enablegc) until
        // the bootstrap has completed.
        // Also, malloc gets called in the guts