[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;
----------------
smithp35 wrote:

Could be worth calling diff `incompatible` not quite as precise as diff, but it matches the earlier comment about incompatible flags. Works quite well with 
```
if (incompatible)
  load = nullptr;
```

Not got a strong opinion, could go with either.

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


More information about the llvm-commits mailing list