[Cbe-oss-dev] elfspe & argument passing

Jeremy Kerr jk at ozlabs.org
Thu Jul 5 09:57:36 EST 2007


Hi all,

libspe2/elfspe/elfspe.c has the following comment:

> /* spe_copy_argv - setup C99-style argv[] region for SPE main().
>  *
>  * Duplicate command line arguments and set up argv pointers
>  * to be absolute LS offsets, allowing SPE program to directly
>  * reference these strings from its own LS.
>  *
>  * An SPE entry function (crt0.o) can take the data from spe_regs
>  * and copy the argv region from EA to the top of LS (largest addr),
>  * and set $SP per ABI requirements. 

However, we never copy this "argv region" to the ls, and I can't see 
anywhere where crt0 is doing a dma to the top of LS either, or see the 
value of the arguments (to the PPE main) anywhere in local store.

Also, it looks like the stack pointer isn't being decremented either.

Hence, doing a spe program with the standard prototype:

 int main(int argc, char **argv)

just breaks in random places. argc is correct, but the address that argv 
points to is in someone else's stack frame, and definitely not to a 
char**.

A couple of questions:

 * do I need to to do anything extra to make crt0 do the setup 
correctly?

 * why does it need to be done in crt0 (hence causing an extra DMA) 
anyway? This could done in libspe instead, where we set up the original 
registers. We'd just need to copy the argv region to the top of local 
store, and offset the stack pointer appropriately.

Cheers,


Jeremy



More information about the cbe-oss-dev mailing list