kernel size
Posted: Mon Mar 01, 2010 7:33 am
Hi! All this tutorials and forum posts have helped me a lot! I have just started my own "OS", and I am planning on keeping the memory management very simple. No multitasking, no applications, no paging, just the kernel in ring 0. I can set the VGA with the bios, draw on screen with flipping, well anyway,
my question is about the size of my kernel. I have found a couple of posts about it already, and I just wanted to have some more info about it.
I put a symbol end in my linker-script, after the code and data, and before bss, and I tried the following:
- extern int end; // C
printf("bla %d", &end - 0x100000); // wrong size, size is +- 350000 decimal, is too big, (i dont know if that 1MB in hex is 1MB, but I just put a couple of zero's in there for this post, in my code it's the correct size anyway)
- as a parameter in main(void * end) pushed from asm
push end ; .asm
printf("bla %d", end); // same as above
My linker script uses the aout format ("binary"). My kernel starts at 1MB.
From what I understand the size end - 1MB should be 8192, (2x 4096 for .text and data)? correct me if I am wrong.
Further more I have another question about the size of my kernel.
I have put a global char LARGE_BUFFER[FFFFFF] in a C file, and I guess that goes into the bss section, because it's uninitialized data. In that file I do a memset on all those bytes, and all is fine. When I set the bios in VMware to include the memory gap at 15MB, grub correctly complains about the size of my kernel.
What I dont understand is where the linker-script fits in all this. In there the bss is 8192 bytes, so how can I put such a large buffer in there. Furthermore why do I have to set a bss section in my assembly code as well? And what is the relationship with that and the likerscript?
Is it correct for me to assume that the code should not get bigger than 4096 because it will overlap the data, and should data not get bigger than 4096 because it overlaps bss, and to assume that it doesnt matter how big bss is, because it wont overlap anything?
Thanks for your time reading this, sry for the bad english, and thanks in advance for comments/answers!
Matthijs Dinant
my question is about the size of my kernel. I have found a couple of posts about it already, and I just wanted to have some more info about it.
I put a symbol end in my linker-script, after the code and data, and before bss, and I tried the following:
- extern int end; // C
printf("bla %d", &end - 0x100000); // wrong size, size is +- 350000 decimal, is too big, (i dont know if that 1MB in hex is 1MB, but I just put a couple of zero's in there for this post, in my code it's the correct size anyway)
- as a parameter in main(void * end) pushed from asm
push end ; .asm
printf("bla %d", end); // same as above
My linker script uses the aout format ("binary"). My kernel starts at 1MB.
From what I understand the size end - 1MB should be 8192, (2x 4096 for .text and data)? correct me if I am wrong.
Further more I have another question about the size of my kernel.
I have put a global char LARGE_BUFFER[FFFFFF] in a C file, and I guess that goes into the bss section, because it's uninitialized data. In that file I do a memset on all those bytes, and all is fine. When I set the bios in VMware to include the memory gap at 15MB, grub correctly complains about the size of my kernel.
What I dont understand is where the linker-script fits in all this. In there the bss is 8192 bytes, so how can I put such a large buffer in there. Furthermore why do I have to set a bss section in my assembly code as well? And what is the relationship with that and the likerscript?
Is it correct for me to assume that the code should not get bigger than 4096 because it will overlap the data, and should data not get bigger than 4096 because it overlaps bss, and to assume that it doesnt matter how big bss is, because it wont overlap anything?
Thanks for your time reading this, sry for the bad english, and thanks in advance for comments/answers!
Matthijs Dinant