Do not mark pages executable unnecessarily to play nice with selinux
Change-Id: Ief4a5da38ac7c2cf7bf6f7a640cb63c5e8ed03bd
diff --git a/runtime/elf_file.cc b/runtime/elf_file.cc
index cb4ef81..da122e6 100644
--- a/runtime/elf_file.cc
+++ b/runtime/elf_file.cc
@@ -587,7 +587,7 @@
return loaded_size;
}
-bool ElfFile::Load() {
+bool ElfFile::Load(bool executable) {
// TODO: actually return false error
CHECK(program_header_only_) << file_->GetPath();
for (llvm::ELF::Elf32_Word i = 0; i < GetProgramHeaderNum(); i++) {
@@ -630,7 +630,7 @@
}
byte* p_vaddr = base_address_ + program_header.p_vaddr;
int prot = 0;
- if ((program_header.p_flags & llvm::ELF::PF_X) != 0) {
+ if (executable && ((program_header.p_flags & llvm::ELF::PF_X) != 0)) {
prot |= PROT_EXEC;
}
if ((program_header.p_flags & llvm::ELF::PF_W) != 0) {