News for hackers. Stuff that matters.
Re:Apple's new library format combines the best of dynamic a... by asveikau on Thursday June 08, 2023 @02:08PM (#36246131)
I think deduping distinct but equal memory pages and marking them as copy on write is a relatively new feature in kernels. Easily 20 years later than shared libraries becoming common.
Re:Apple's new library format combines the best of dynamic a... by eru on Thursday June 08, 2023 @10:24PM (#36252328)
In this case you wouldn't need copy-on-write, because executable pages aren't writeable these days. https://en.wikipedia.org/wiki/W%5EX
Re:Apple's new library format combines the best of dynamic a... by asveikau on Thursday June 08, 2023 @11:18PM (#36252694)
I'd say from a kernel perspective they should be copy-on-write.

Firstly, the generalized kernel mechanism which scans for equal pages and de-dupes them [which by the way is disabled by default on Linux] probably doesn't care about if it's working on data or code; it seems like the primary use case at its introduction was for KVM, which, a kernel probably loads code pages and hence writes to them at some point, such as when it reads them from disk.

Second, someone can use mprotect(2) to make them writeable.