All non-executable sections used to be mapped as RW- causing read-only
sections such as .rodata to be writable.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D147442
});
// Get the section's memory protection flags.
- orc::MemProt Prot;
+ orc::MemProt Prot = orc::MemProt::Read;
if (Sec.sh_flags & ELF::SHF_EXECINSTR)
- Prot = orc::MemProt::Read | orc::MemProt::Exec;
- else
- Prot = orc::MemProt::Read | orc::MemProt::Write;
+ Prot |= orc::MemProt::Exec;
+ if (Sec.sh_flags & ELF::SHF_WRITE)
+ Prot |= orc::MemProt::Write;
// Look for existing sections first.
auto *GraphSec = G->findSectionByName(*Name);