To load the image of ELF executable in memory need:
.Text + . Data + . Bss. This is already.
Now. How do I know the STACK size it need? It dynamically assigns an? What size is recommended?
thanks for the reply
cheers
'STACK' of ELF executable in Memory
'STACK' of ELF executable in Memory
Last edited by okaox on Sat Nov 21, 2009 10:18 am, edited 1 time in total.
Re: 'STACK' of ELF executable Image
Hi,
For third party user processes, unfortunately that's an unknown. One of the common ways to deal with this seems to be to set up a small initial stack with an unmapped "guard page" close to the top of your process space. Every time there is a page fault in the guard page, you extend the stack (until the point where the guard page hits the heap or some predetermined value). Note that if you do this for a ring 0 process, you'll need to handle your PFE by using either an IST (64 bit) or task gate (32 bit) to provide the required stack switching.
If you are deciding this for a kernel image, you should be able to pretty much guess how much you need. Are you in pure ASM, making little use of recursion? If so, you need a pretty small stack (maybe only a page or two). Are you in C++ returning large objects on the stack and using recursion in your VFS? If so, a few MiB could easily be required.
Cheers,
Adam
For third party user processes, unfortunately that's an unknown. One of the common ways to deal with this seems to be to set up a small initial stack with an unmapped "guard page" close to the top of your process space. Every time there is a page fault in the guard page, you extend the stack (until the point where the guard page hits the heap or some predetermined value). Note that if you do this for a ring 0 process, you'll need to handle your PFE by using either an IST (64 bit) or task gate (32 bit) to provide the required stack switching.
If you are deciding this for a kernel image, you should be able to pretty much guess how much you need. Are you in pure ASM, making little use of recursion? If so, you need a pretty small stack (maybe only a page or two). Are you in C++ returning large objects on the stack and using recursion in your VFS? If so, a few MiB could easily be required.
Cheers,
Adam
Re: 'STACK' of ELF executable in Memory
Ok Adam.
Thanks
Sebas
Thanks
Sebas