1
0
mirror of https://github.com/golang/go synced 2024-11-20 08:04:42 -07:00

cmd/ld: add PT_PAX_FLAGS ELF header

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
This commit is contained in:
Russ Cox 2012-08-03 15:27:35 -04:00
parent cf06750372
commit 3f34248a77
3 changed files with 11 additions and 0 deletions

View File

@ -1083,6 +1083,11 @@ asmb(void)
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;
sh->addralign = 1;

View 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;

View 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. */