[PATCH] D147442: [JITLink][ELF] Only make sections with SHF_WRITE writable
Job Noorman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 3 07:01:20 PDT 2023
jobnoorman created this revision.
jobnoorman added a reviewer: lhames.
Herald added subscribers: asb, pmatos, hiraditya.
Herald added a project: All.
jobnoorman requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
All non-executable sections used to be mapped as RW- causing read-only
sections such as .rodata to be writable.
Note that this patch doesn't include a test case since it's not entirely
clear to me if it's possible to test MemProt flags.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147442
Files:
llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
Index: llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
+++ llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
@@ -360,11 +360,11 @@
});
// 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147442.510490.patch
Type: text/x-patch
Size: 772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230403/4a43468a/attachment.bin>
More information about the llvm-commits
mailing list