kernel size

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
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

kernel size

Post by Srowen »

my kernel compiled is 12kb and i define a stack of 8 kb. so the kernel should be about 20kb.. but if i try to calculate it with the end of the kernel (i use a symbol at the end of the linker) and the kernel start, i can see that is 104kb! there's something wrong on my operations or it is possible that the kernel is so big??

sorry for my bad english...
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: kernel size

Post by neon »

It might have to do with padding and/or alignment of the sections in your kernel binary. Hard to tell without looking at a linker map.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

Re: kernel size

Post by Srowen »

here is the linker:

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
  .text phys : AT(phys) {
    code = .;
    *(.text)
    *(.rodata)
    . = ALIGN(4096);
  }
  .data : AT(phys + (data - code))
  {
    data = .;
    *(.data)
    . = ALIGN(4096);
  }
  .bss : AT(phys + (bss - code))
  {
    bss = .;
    *(.bss)
    . = ALIGN(4096);
  }
  end = .;
}
that is nothing more then the Bran's tutorial..
skyking
Member
Member
Posts: 174
Joined: Sun Jan 06, 2008 8:41 am

Re: kernel size

Post by skyking »

What you need to do is to run objdump and then you see what's in your kernel. What section is occupying too much space. And when you've seen this you can use objdump to see what symbols are present in that section.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: kernel size

Post by jal »

Srowen wrote:i can see that is 104kb! there's something wrong on my operations or it is possible that the kernel is so big??
Have you stripped the kenel? If not, all symbols may be present making it big. If it's an ELF file, using elfdump or the like to check.


JAL
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Re: kernel size

Post by Craze Frog »

jal wrote:
Srowen wrote:i can see that is 104kb! there's something wrong on my operations or it is possible that the kernel is so big??
Have you stripped the kenel? If not, all symbols may be present making it big. If it's an ELF file, using elfdump or the like to check.


JAL
What does the first line of his linker script say?
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: kernel size

Post by jal »

Craze Frog wrote:What does the first line of his linker script say?
Sorry, hit that reply button too fast. Won't do again, promise.


JAL
skyking
Member
Member
Posts: 174
Joined: Sun Jan 06, 2008 8:41 am

Re: kernel size

Post by skyking »

Craze Frog wrote:
jal wrote:
Srowen wrote:i can see that is 104kb! there's something wrong on my operations or it is possible that the kernel is so big??
Have you stripped the kenel? If not, all symbols may be present making it big. If it's an ELF file, using elfdump or the like to check.


JAL
What does the first line of his linker script say?
Well it wouldn't hurt to output an ELF variant of the kernel as well (or a mapfile). It's not fun to read through a 104kb binary file to see what's occupying all space.
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Re: kernel size

Post by Craze Frog »

Is the file really 104kb? Or is it just your calculations?
Post Reply