diff options
author | Rui Ueyama <ruiu@google.com> | 2017-02-23 08:09:51 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2017-02-23 08:09:51 +0000 |
commit | a7e87252ceca796fbd6735d9e66bf60a33e8ab04 (patch) | |
tree | 4b68dbb279718aa8c96f2b5f1234581a038d6c43 /lld/ELF/Writer.cpp | |
parent | fd939c0f6c9e036848f22f94ab00fbc4fadb1e2d (diff) | |
download | bcm5719-llvm-a7e87252ceca796fbd6735d9e66bf60a33e8ab04.tar.gz bcm5719-llvm-a7e87252ceca796fbd6735d9e66bf60a33e8ab04.zip |
Always add PT_GNU_STACK.
If -z stack-size is given, we need to add PT_GNU_STACK even if
-z execstack is not given.
llvm-svn: 295945
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r-- | lld/ELF/Writer.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 51253f14f55..d7278cd6110 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1334,9 +1334,15 @@ template <class ELFT> std::vector<PhdrEntry> Writer<ELFT>::createPhdrs() { AddHdr(PT_OPENBSD_RANDOMIZE, Sec->getPhdrFlags())->add(Sec); // PT_GNU_STACK is a special section to tell the loader to make the - // pages for the stack non-executable. - if (!Config->ZExecstack) - AddHdr(PT_GNU_STACK, PF_R | PF_W)->p_memsz = Config->ZStackSize; + // pages for the stack non-executable. If you really want an executable + // stack, you can pass -z execstack, but that's not recommended for + // security reasons. + unsigned Perm; + if (Config->ZExecstack) + Perm = PF_R | PF_W | PF_X; + else + Perm = PF_R | PF_W; + AddHdr(PT_GNU_STACK, Perm)->p_memsz = Config->ZStackSize; // PT_OPENBSD_WXNEEDED is a OpenBSD-specific header to mark the executable // is expected to perform W^X violations, such as calling mprotect(2) or |