diff options
| author | Russ Cox <rsc@golang.org> | 2012-10-09 12:50:06 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-10-09 12:50:06 -0400 |
| commit | f76f120324f449cff3fdaeb05effbe18162e0cf1 (patch) | |
| tree | f47f21a6dadd38e3eacb65bd088611af1969a85e /src | |
| parent | 3aae5a0e7ec1f6802844e35ed72aaa929145b2e5 (diff) | |
| download | go-f76f120324f449cff3fdaeb05effbe18162e0cf1.tar.xz | |
cmd/ld: use 64-bit alignment for large data and bss objects
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/ld/data.c | 5 | ||||
| -rw-r--r-- | src/pkg/runtime/mgc0.c | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/ld/data.c b/src/cmd/ld/data.c index 89eccd143c..4afe4b801c 100644 --- a/src/cmd/ld/data.c +++ b/src/cmd/ld/data.c @@ -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); diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c index 6c2ce00953..dc3b877c4e 100644 --- a/src/pkg/runtime/mgc0.c +++ b/src/pkg/runtime/mgc0.c @@ -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 |
