]> Cypherpunks repositories - gostls13.git/commitdiff
6l, 8l: include ELF header in PT_LOAD mapping for text segment
authorRuss Cox <rsc@golang.org>
Wed, 21 Apr 2010 03:39:55 +0000 (20:39 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 21 Apr 2010 03:39:55 +0000 (20:39 -0700)
Due to page boundary rounding, the header would have
been loaded as part of the text segment already, but this
change placates the "paxctl" tool on so-called hardened
Linux distributions (as if normal distributions weren't already
hard enough to use).

R=r
CC=golang-dev
https://golang.org/cl/954041

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

index af00f559446b9f1f1e41b8c14a02471237519a90..b83cec68fbd2eee590649975fd7f36f32f1dddf7 100644 (file)
@@ -713,11 +713,11 @@ asmb(void)
                ph = newElfPhdr();
                ph->type = PT_LOAD;
                ph->flags = PF_X+PF_R;
-               ph->vaddr = va;
-               ph->paddr = va;
-               ph->off = fo;
-               ph->filesz = w;
-               ph->memsz = w;
+               ph->vaddr = va - fo;
+               ph->paddr = va - fo;
+               ph->off = 0;
+               ph->filesz = w + fo;
+               ph->memsz = w + fo;
                ph->align = INITRND;
 
                fo = rnd(fo+w, INITRND);
index eddf6617b18c7ad57c3d93aa65e098980f42e374..4e8c0560d9b1e16ae01708ac05c7ff9b776e102a 100644 (file)
@@ -829,11 +829,11 @@ asmb(void)
                ph = newElfPhdr();
                ph->type = PT_LOAD;
                ph->flags = PF_X+PF_R;
-               ph->vaddr = va;
-               ph->paddr = va;
-               ph->off = fo;
-               ph->filesz = w;
-               ph->memsz = w;
+               ph->vaddr = va - fo;
+               ph->paddr = va - fo;
+               ph->off = 0;
+               ph->filesz = w + fo;
+               ph->memsz = w + fo;
                ph->align = INITRND;
 
                fo = rnd(fo+w, INITRND);