3GB kernel binary!

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
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

3GB kernel binary!

Post by Colonel Kernel »

Wow, something went really wrong here. For a long time I've been running two parallel builds of my kernel -- one that passes -D NDEBUG to gcc (my "free" build) and one without (my "checked" build). I added -O3 to the compiler settings for my free build, and suddenly my kernel binary grows from 23KB to 3GB!

I'm guessing there is something subtle that I don't understand about my linker script, since my kernel is linked to run in the higher half. Here it is:

Code: Select all

ENTRY (StartPrecursor)

OUTPUT_FORMAT(binary)
SECTIONS
{
    . = 0xC0100000;

    .text :
    {
        *(.text)
        *(.rodata)
    }

    .data ALIGN (0x1000) :
    {
        *(.data)
    }

    .bss :
    {
        _sbss = .;
        *(COMMON)
        *(.bss)
        _ebss = .;
    }
}
Are there any magical sections I'm not aware of that would only show up when compiling with -O3 (or any of the -O's, they all do the same thing)? BTW, I'm using a gcc cross-compiler (built from gcc 3.4.1 sources according to the instructions on the OS FAQ).
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
pradeep

Re:3GB kernel binary!

Post by pradeep »

Well i really don't know the answer but the same question was posted long back and i think it was answered by Pype.Clicker better he could give you the answer
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:3GB kernel binary!

Post by Colonel Kernel »

Thanks for mentioning Pype's name -- that finally got me some results in the forum's search function. :)

Apparently, using -O3 was causing some of the string constants to go in sections named .rodata.strx.y. This fixed it:

Code: Select all

ENTRY (StartPrecursor)

OUTPUT_FORMAT(binary)
SECTIONS
{
    . = 0xC0100000;

    .text :
    {
        *(.text)
        *(.rodata*)               /* <--- aha! */
    }

    .data ALIGN (0x1000) :
    {
        *(.data)
    }

    .bss :
    {
        _sbss = .;
        *(COMMON)
        *(.bss)
        _ebss = .;
    }
}
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:3GB kernel binary!

Post by Pype.Clicker »

;D ROFL. Just invoke my name and your kernel will automagically debug :P
For I am the mighty wizard of OS. How wizzy your OS is, the wizard has a wizzer for your for nothing is too wizzy for the wize wizard of OS. ;D

(seems i'm in a hilarous-like-BI day :P)
DruG5t0r3

Re:3GB kernel binary!

Post by DruG5t0r3 »

Follow the binary brick wall ;D
0Scoder
Member
Member
Posts: 53
Joined: Sat Nov 11, 2006 8:02 am

Re:3GB kernel binary!

Post by 0Scoder »

lol, could be an advert for broadband: Follow the megabit road could be a nice slogan
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:3GB kernel binary!

Post by Pype.Clicker »

@oscoder: i suppose "follow the white megrabit" will hit broader audience
@drugstore: actually, it's "The Road of Yellow Bits".
Post Reply