Stack Considerations.

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
elderK

Stack Considerations.

Post by elderK »

Hey guys, Im just curious.

The Kernel Binary doesnt just take up the room ... that it is on disk, right?

I mean, it has DATA / RDATA / BSS Segments right?

So, 0x8000 (my kernel location) + KERNEL_FILESIZE = Not space I can overwrite? (So, I couldnt place my stack (0x8000 + KSIZE)+0x1000 )

Im trying to make a 4KiB stack for the Kernel, so far - the Kernel Stack is at 0x20000. Seems way too high up, id rather relocate it somewhere that makes more sense. Thats closer to the kernel, so all that space between isnt wasted.

Any advice?
~Zeii.
nick8325
Member
Member
Posts: 200
Joined: Wed Oct 18, 2006 5:49 am

Re:Stack Considerations.

Post by nick8325 »

You could put the stack inside the BSS, I suppose. Something like (in NASM):

Code: Select all

section .bss
resb 4096
stack_top:
Then mov esp, stack_top will set the stack.

EDIT: actually, for efficiency, the stack pointer should be aligned. So something like mov esp, stack_top; and esp, 0xFFFFFFF0 might be better.
Bob the Avenger

Re:Stack Considerations.

Post by Bob the Avenger »

or you could tell nasm to align it using ALIGN 4, that way you dont looks any of your page of stack

Peace
Post Reply