ELF loading and the stack

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
StereoRocker
Posts: 4
Joined: Sun Mar 18, 2012 9:06 am
Libera.chat IRC: StereoRocker
Location: At the computer
Contact:

ELF loading and the stack

Post by StereoRocker »

Hi everyone,

I've recently started getting back into OSDev, and I'm at a point with my kernel where I can start implementing ELF loading.
There's one thing that's tripping me up, and that's finding out information about the stack with regards to ELF files.

I need to know if it's the kernel's responsibility to allocate a stack to the process and ensure that it's valid and active, or whether a suitable stack is defined within the program headers and the _start function sets this up accordingly.

(I have searched to see if this topic has been posted previously, but didn't find anything. I apologise if it indeed has been asked already!)

Thanks,
NFSGamer
embryo2
Member
Member
Posts: 397
Joined: Wed Jun 03, 2015 5:03 am

Re: ELF loading and the stack

Post by embryo2 »

NFSGamer wrote:I need to know if it's the kernel's responsibility to allocate a stack to the process and ensure that it's valid and active, or whether a suitable stack is defined within the program headers and the _start function sets this up accordingly.
It's a design issue. And that's why it means you have to decide it on your own.

Generally the kernel manages processes and the management includes process's stack and some data structures. But you can implement a system where some external entity has created the stack and data structures. It's, of course, looks very inefficient, because you lose control over many essential parts of your system. But if you want to create something "new" then why not?
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)
StereoRocker
Posts: 4
Joined: Sun Mar 18, 2012 9:06 am
Libera.chat IRC: StereoRocker
Location: At the computer
Contact:

Re: ELF loading and the stack

Post by StereoRocker »

I see. I think I'll go with kernel managed stack space then. Though it would be interesting to see the alternative put to use.

Thanks for your help!
Post Reply