]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: add PT_PAX_FLAGS ELF header
authorRuss Cox <rsc@golang.org>
Fri, 3 Aug 2012 19:27:35 +0000 (15:27 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 3 Aug 2012 19:27:35 +0000 (15:27 -0400)
PAX systems are Linux systems that are more paranoid about memory permissions.
These flags tell them to relax when running Go binaries.

Fixes #47.

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

src/cmd/6l/asm.c
src/cmd/8l/asm.c
src/cmd/ld/elf.h

index 8d8c6d725c04b6c9197feef6b2bab539ba1363b6..a9901c737480e0fa989cee0b2d0eb485f2c71f58 100644 (file)
@@ -1082,6 +1082,11 @@ asmb(void)
                ph->type = PT_GNU_STACK;
                ph->flags = PF_W+PF_R;
                ph->align = 8;
+               
+               ph = newElfPhdr();
+               ph->type = PT_PAX_FLAGS;
+               ph->flags = 0x2a00; // mprotect, randexec, emutramp disabled
+               ph->align = 8;
 
                sh = newElfShstrtab(elfstr[ElfStrShstrtab]);
                sh->type = SHT_STRTAB;
index 6c3a76e4d4e6122e6c684e578f5741c6e846b036..99c9b238b128abd333212f01d1f650763448ba5a 100644 (file)
@@ -1127,6 +1127,11 @@ asmb(void)
                ph->flags = PF_W+PF_R;
                ph->align = 4;
 
+               ph = newElfPhdr();
+               ph->type = PT_PAX_FLAGS;
+               ph->flags = 0x2a00; // mprotect, randexec, emutramp disabled
+               ph->align = 4;
+
                sh = newElfShstrtab(elfstr[ElfStrShstrtab]);
                sh->type = SHT_STRTAB;
                sh->addralign = 1;
index cfe1f9e53c8d1876e045ab53133eba826ef88537..13c3d4da1f599550efb8f2e0a6d530941d16d26f 100644 (file)
@@ -251,6 +251,7 @@ typedef struct {
 #define PT_LOPROC      0x70000000      /* First processor-specific type. */
 #define PT_HIPROC      0x7fffffff      /* Last processor-specific type. */
 #define PT_GNU_STACK   0x6474e551
+#define PT_PAX_FLAGS   0x65041580
 
 /* Values for p_flags. */
 #define PF_X           0x1             /* Executable. */