Page 1 of 1

3GB kernel binary!

Posted: Sat Oct 08, 2005 6:25 pm
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).

Re:3GB kernel binary!

Posted: Sat Oct 08, 2005 9:07 pm
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

Re:3GB kernel binary!

Posted: Sat Oct 08, 2005 11:34 pm
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 = .;
    }
}

Re:3GB kernel binary!

Posted: Sun Oct 09, 2005 4:15 am
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)

Re:3GB kernel binary!

Posted: Sun Oct 09, 2005 1:13 pm
by DruG5t0r3
Follow the binary brick wall ;D

Re:3GB kernel binary!

Posted: Sun Oct 09, 2005 3:11 pm
by 0Scoder
lol, could be an advert for broadband: Follow the megabit road could be a nice slogan

Re:3GB kernel binary!

Posted: Sun Oct 09, 2005 3:26 pm
by Pype.Clicker
@oscoder: i suppose "follow the white megrabit" will hit broader audience
@drugstore: actually, it's "The Road of Yellow Bits".