Replies: 1 comment 5 replies
-
It's not a custom calling convention; it uses the standard calling convention, but the types are constrained to only the primitive types because anything more than that essentially requires using the stack**, which means reading/writing memory, which is why it needs to be done manually and not automagically hidden behind macro machinery. (** - except the small types like
I'm not entirely sure what you're trying to say here, but yes, you can use standard tooling to produce libraries/link multiple libraries/whatever, and only at the very end build a single ELF file and pass that into
To be able to statically figure out which exact host calls are used by a given binary; with Note that
To explicitly have a list of imports/exports, instead of relying on the janky system that native binaries use where undefined symbols are imports (and we can't tell whether an undefined symbol is meant to be an import, or it's a programmer error) and visible symbols are exports (there's usually a lot of garbage symbols that are unintentionally emitted as visible, especially when people write C). Having the macros and using custom sections for imports/exports sidesteps these issues. |
Beta Was this translation helpful? Give feedback.
-
This might be one of those stupid questions because I do not really know what I'm talking about here.
However, I was reading https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc a few days ago and now wondering why it doesn't seem to be used instead of what seems to be a custom calling convention that constraints inputs to [i|u][32|64|size]?
For example it would be possible to use small structs or other integer types (like
u8
) as long as caller can set up registers correctly. Also since PVM is effectively a library, maybe it would be possible to compile it as an actual library instead of binary. That way library before linking withpolkatool
might be usable as a regular C library.Calls to the host are a bit different of course due to
ecalli
usage, but similar logic generally applies I think. BTW I was trying to understand what why isecalli
used instead ofecall
, but didn't really find an explanation, I also failed to find anything relevant in chapters 19 of both unprivileged and privileged specs mentioned here (actual link to the spec and version would be nice.I might be completely off here, in which case I'd appreciate links where I can learn more about this stuff.
Beta Was this translation helpful? Give feedback.
All reactions