summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2010-06-11 13:41:49 -0700
committerIan Lance Taylor <iant@golang.org>2010-06-11 13:41:49 -0700
commita0864402def5517e2172cae7c2976950adfadeb8 (patch)
tree2d1bc40d42b31691557ce188fd75b5acc9610050 /src
parent0711ab15504895a329f015807e51b2ca7cd38b47 (diff)
downloadgolang-a0864402def5517e2172cae7c2976950adfadeb8.tar.gz
Pad Go symbol table out to page boundary when linking dynamically.
This avoids a crash when using cgo where glibc's malloc thinks that it can use some of the memory following the symbol table. This fails because the symbol table is mapped read-only, which affects the whole page. R=rsc CC=golang-dev http://codereview.appspot.com/1616042
Diffstat (limited to 'src')
-rw-r--r--src/cmd/5l/asm.c6
-rw-r--r--src/cmd/6l/asm.c6
-rw-r--r--src/cmd/8l/asm.c6
3 files changed, 11 insertions, 7 deletions
diff --git a/src/cmd/5l/asm.c b/src/cmd/5l/asm.c
index 62c2a07ad..45e6e734f 100644
--- a/src/cmd/5l/asm.c
+++ b/src/cmd/5l/asm.c
@@ -532,6 +532,8 @@ asmb(void)
asmthumbmap();
if(dlm)
asmdyn();
+ if(!debug['s'])
+ strnput("", INITRND-(8+symsize+lcsize)%INITRND);
cflush();
seek(cout, symo, 0);
lputl(symsize);
@@ -679,8 +681,8 @@ asmb(void)
ph->off = symo;
ph->vaddr = symdatva;
ph->paddr = symdatva;
- ph->filesz = 8+symsize+lcsize;
- ph->memsz = 8+symsize+lcsize;
+ ph->filesz = rnd(8+symsize+lcsize, INITRND);
+ ph->memsz = rnd(8+symsize+lcsize, INITRND);
ph->align = INITRND;
}
diff --git a/src/cmd/6l/asm.c b/src/cmd/6l/asm.c
index c104d23d4..b45557ebe 100644
--- a/src/cmd/6l/asm.c
+++ b/src/cmd/6l/asm.c
@@ -620,6 +620,8 @@ asmb(void)
asmlc();
if(dlm)
asmdyn();
+ if(!debug['s'])
+ strnput("", INITRND-(8+symsize+lcsize)%INITRND);
cflush();
seek(cout, symo, 0);
lputl(symsize);
@@ -753,8 +755,8 @@ asmb(void)
ph->off = symo;
ph->vaddr = symdatva;
ph->paddr = symdatva;
- ph->filesz = 8+symsize+lcsize;
- ph->memsz = 8+symsize+lcsize;
+ ph->filesz = rnd(8+symsize+lcsize, INITRND);
+ ph->memsz = rnd(8+symsize+lcsize, INITRND);
ph->align = INITRND;
}
diff --git a/src/cmd/8l/asm.c b/src/cmd/8l/asm.c
index 797209169..a7f894aa2 100644
--- a/src/cmd/8l/asm.c
+++ b/src/cmd/8l/asm.c
@@ -642,7 +642,7 @@ asmb(void)
asmlc();
if(dlm)
asmdyn();
- if(HEADTYPE == 10)
+ if(HEADTYPE == 10 || (iself && !debug['s']))
strnput("", INITRND-(8+symsize+lcsize)%INITRND);
cflush();
seek(cout, symo, 0);
@@ -884,8 +884,8 @@ asmb(void)
ph->off = symo;
ph->vaddr = symdatva;
ph->paddr = symdatva;
- ph->filesz = 8+symsize+lcsize;
- ph->memsz = 8+symsize+lcsize;
+ ph->filesz = rnd(8+symsize+lcsize, INITRND);
+ ph->memsz = rnd(8+symsize+lcsize, INITRND);
ph->align = INITRND;
}