-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ROPI/RWPI Specification (Embedded PIC) #128
Comments
From my initial analysis there are a few moving parts to this. Please let me know if I've missed anything. Definition of terms. We are talking about ROPI (read-only position independence) and RWPI (read-write position independence), which are two orthogonal tastes that taste great together:
I'm not aware of an actual spec for the ROPI/RWPI support on ARM. Near as I can tell, it -- and related codegen models like GCC's As a result, I'm thinking about a spec in tandem with toolchain support, so you'll see the two mixed together below. LLVM/Clang have limited upstream ROPI/RWPI support. It currently appears to be ARM specific. GCC has similar support but under different names. Note that the upstreamed support appears to ban static pointers to moveable segments, such as function pointers in ROPI code, or data pointers in RWPI code. C++ is also banned (because vtables and rtti are difficult to implement with the above restriction). We should evaluate Keil's ROPI/RWPI-lowering patches. Originally sent upstream in 2015, it doesn't look like the lowering parts of these changes were merged (too intrusive to Clang, it sounds like). Keil appears to be maintaining them for armclang, however. The lowering passes are critical for lifting the restrictions I mentioned in the previous paragraph. (Are the sufficient? I'm not sure; they seem sufficient...) Perhaps if these patches applied to two architectures they wouldn't be perceived as being quite as intrusive? (Jargon note: this is lowering in the sense used by compiler people, where an operation you don't support natively is expressed in terms of smaller ones that you do.) What degree of changes are needed to the RISC-V ABI?
|
My experience is that embedded pic tends to be very target dependent and everyone creates their own. ropi/rwpi seems to be ARM's contribution to this genre. The FDPIC scheme used by nommu embedded linux is fairly standard across targets, though I don't know if there is a formal spec for it. There is a fdpic register that points at the data section. Function pointers are represented as function descriptors in the data section, where the first word is the address of the function and the second word if the value for the fdpic register. This seems to satisfy your requirements, but it does assume that there is a dynamic linker. There are various target specific fdpic documents available. Otherwise, having some sort of embedded pic scheme would be nice, but we don't necessarily have to copy what ARM has invented. |
True -- I referenced ARM's work only because I know it works and is supported in LLVM. It's worth considering alternatives and how they'd affect code generation. |
@cbiffle @lenary did you mind shared what you expected for the Capability of position-independent code? capability of access data which is place far from the code? or capability of access (load/store/call) anywhere in 64 bits address space? |
Maciej W. Rozycki from WDC proposing FDPIC for RISC-V on |
Hi Kito. To clarify, the main use case we're interested in at lowRISC is embedded microcontrollers (e.g. an RV32 core running Tock with loadable applications). Though if the same approach works well for embedded nommu Linux, that's great. |
Adam Leventhal at Oxide Computer recently asked about a ROPI/RWPI support for RISC-V
This is also something that we (@lowRISC) are interested in, and I think that @alistair23 has been looking at support for this too.
It would be great to coordinate on the development of the specification, before too much of any implementation is written, and the ELF psABI seems like the right place to collaborate (in my opinion). I hope this issue can coordinate discussion on any specification proposals.
The text was updated successfully, but these errors were encountered: