]> Cypherpunks repositories - gostls13.git/commitdiff
ld: fix alignment of rodata section
authorRuss Cox <rsc@golang.org>
Fri, 24 Feb 2012 04:01:36 +0000 (23:01 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 24 Feb 2012 04:01:36 +0000 (23:01 -0500)
We were not aligning the code size,
so read-only data, which follows in the same
segment, could be arbitrarily misaligned.

Fixes #2506.

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

src/cmd/ld/data.c

index 397ae83b2383bc20967a7ab8359dc0ed4142dc31..786c10b64d838707d7b86637a3552334c4b790a2 100644 (file)
@@ -1023,6 +1023,11 @@ textaddress(void)
                }
                va += sym->size;
        }
+       
+       // Align end of code so that rodata starts aligned.
+       // 128 bytes is likely overkill but definitely cheap.
+       va = rnd(va, 128);
+
        sect->len = va - sect->vaddr;
 }