Page 1 of 1

Stack Considerations.

Posted: Mon Sep 11, 2006 10:06 am
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.

Re:Stack Considerations.

Posted: Mon Sep 11, 2006 12:43 pm
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.

Re:Stack Considerations.

Posted: Mon Sep 11, 2006 12:48 pm
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