The interface is implemented for ELF and checks if ALLOC and PROGBITS attributes
are set and WRITE is not set. Not implemented for the rest of formats.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
What's the motivation for this? Why did you decide that anything other than SHF_WRITE has implication on whether a section is read-only or not?
Hi folks, this patch is part of an effort to bring BOLT to the LLVM repo, so the use case comes from BOLT.
The main use case for this is here:
https://github.com/facebookincubator/BOLT/blob/rebased/bolt/src/Passes/BinaryPasses.cpp#L1100
This is a pass that checks for a memory load instruction that is accessing a read-only section, and converts it into "load immediate" to save a data memory access.
Most binary formats have a concept of writable, but not a concept of readonly.
In ELF, you refine readonly to mean something SHF_ALLOC & SHT_PROGBITS which is probably really BOLT specific.
Having the interface in lib/Object will just cause confusion to lib/Object users.
Thank you for the comments. Indeed this "read-only" is not well-defined. What we actually want to test is if the section is writable or not. Abandoning this diff.