[lld] [ELF] --no-rosegment: don't mark read-only PT_LOAD segments executable (PR #81223)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 9 08:06:03 PST 2024


================
@@ -2465,13 +2460,22 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
     // so when hasSectionsCommand, since we cannot introduce the extra alignment
     // needed to create a new LOAD)
     uint64_t newFlags = computeFlags(sec->getPhdrFlags());
+    // When --no-rosegment is specified, RO and RX sections are compatible.
+    uint32_t diff = flags ^ newFlags;
+    if (config->singleRoRx && !(newFlags & PF_W))
+      diff &= ~PF_X;
----------------
smithp35 wrote:

There's an interesting conflict here between singleRoRx and execute-only, could be worth making these options incompatible in Driver.cpp as singleRoRx breaks execute-only.

This isn't a regression caused by this patch though so could be done in a different patch.

https://github.com/llvm/llvm-project/pull/81223


More information about the llvm-commits mailing list