[Multiboot/GRUB] Kernel size (solved)

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
neil
Posts: 8
Joined: Fri Feb 25, 2005 12:00 am
Location: Nice, France
Contact:

[Multiboot/GRUB] Kernel size (solved)

Post by neil »

Does anyone know how could I get the size of the kernel loaded by GRUB (or any multiboot compliant boot loader) ?
Maybe I need to look in the ELF sections, but are all the ELF sections loaded by GRUB or only BITS|PROGBITS ?
neil
Posts: 8
Joined: Fri Feb 25, 2005 12:00 am
Location: Nice, France
Contact:

Re: [Multiboot/GRUB] Kernel size (solved)

Post by neil »

After reading the memory it seems that all the sections are loaded by GRUB.
So I juste need to add the last ELF section header and its size to get the end of kernel address.
Last edited by neil on Tue Mar 08, 2005 12:00 am, edited 1 time in total.
Crazed123
Member
Member
Posts: 248
Joined: Thu Oct 21, 2004 11:00 pm

Re: [Multiboot/GRUB] Kernel size (solved)

Post by Crazed123 »

Not solved for me. I've tried to declare a symbol in my linker script to hold the end-of-kernel address like so:

Code: Select all

ENTRY(_start)
OUTPUT_FORMAT("elf32-i386")

SECTIONS
{
    . = 0x00100000;

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

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

    .bss :
    {
        _sbss = .;
        *(COMMON)
        *(.bss)
        _ebss = .;
    }

    KernelEnd = .;
}
But whenever I link the symbol (KernelEnd) evaluates to zero.

What, did you want me to start a new topic?
Last edited by Crazed123 on Mon Jul 25, 2005 11:00 pm, edited 1 time in total.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: [Multiboot/GRUB] Kernel size (solved)

Post by carbonBased »

kernelEnd == 0

&kernelEnd == what you're looking for.

Linker symbols have no value, only addresses.

--Jeff
Crazed123
Member
Member
Posts: 248
Joined: Thu Oct 21, 2004 11:00 pm

Re: [Multiboot/GRUB] Kernel size (solved)

Post by Crazed123 »

And why is that?

Also, the same thing happens with the symbols I define in my assembler stub.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: [Multiboot/GRUB] Kernel size (solved)

Post by carbonBased »

Because they're just symbols, not actual variables.

Think of them as labels, or pointers. You aren't creating a new variable, but rather pointing to an existing one (or location).

--Jeff
Post Reply