Hello, On Wed, 13 Oct 2021, Martin Uecker wrote:
> does anybody know if all architectures support passing > an environment pointer in their function call ABI? Define "environment pointer". I can imagine two things you could mean: the custom to pass envp as third argument to main() in hosted C programs: int main (int argc, char *argv[], char *envp[]); but then this is specific to main and more a question of process initialization than function call ABI. If you mean this the answer will most often be: if envp is passed to main (a question of the operating system or runtime environment, e.g. if there's something like an environment in the getenv() sense to start with), then it is passed like any other third argument of pointer type on the psABI in question, and that definition would be independend of the psABI. Or you could mean what normally would be called 'static chain', i.e. a pointer to the stack frame of outer functions for languages supporting nested functions. I could imagine this also be called environment. If you mean that, then it's indeed psABI specific, and possibly not all ABIs specify it (in which case GCC will probably have set a de-facto standard at least for unixy systems). The x86-64 psABI for instance does specify a register for this, which is separate from the normal argument passing registers. Other psABIs could say that it's passed like a hidden argument prepended to the formal list of args. Or do you mean something else entirely? It might also help to know the purpose of your question :) Ciao, Michael.