]> Cypherpunks repositories - gostls13.git/commitdiff
Pad Go symbol table out to page boundary when linking dynamically.
authorIan Lance Taylor <iant@golang.org>
Fri, 11 Jun 2010 20:41:49 +0000 (13:41 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 11 Jun 2010 20:41:49 +0000 (13:41 -0700)
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
https://golang.org/cl/1616042

src/cmd/5l/asm.c
src/cmd/6l/asm.c
src/cmd/8l/asm.c

index 62c2a07ad8b9c6e0033305bc2243a306e3342200..45e6e734fbef42e3b6299f326b489a12d496f588 100644 (file)
@@ -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;
                }
 
index c104d23d4b5b184de3db5f41e540ab30b3242dff..b45557ebe7ce4f4e3db6905618194b872645c0de 100644 (file)
@@ -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;
                }
 
index 797209169dfab9c8271efe9c5a61f628ad6b047b..a7f894aa281a61af1312ab7f3376f682f801e985 100644 (file)
@@ -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;
                }