Page 1 of 1
having grub load with different virtual address?
Posted: Fri Mar 19, 2004 11:49 am
by proxy
Hi all, I am currently using grub to load my kernel at 1meg, I was wondering if it was possible to have grub load the kernel with a different virtual address (say 0xc0000000) but if i try having my linker use that as it's base address it get an error in grub, somthing along the lines of the binary cannot fit in memory.
I noticed that the Linux kernel is linked at 0xc0000000 and obviously boots just fine. Anyone have any experience with this?
proxy
Re:having grub load with different virtual address?
Posted: Fri Mar 19, 2004 2:45 pm
by frank
(say 0xc0000000)
Grub can not load at that high addresses.
See:
http://www.openbg.net/sto/os/xml/grub.html
Re:having grub load with different virtual address?
Posted: Fri Mar 19, 2004 4:31 pm
by proxy
but in code listing 11 they have an example where virtual address is aexactly where i want it!...so what do i need to do? other OSes seem to do it...
proxy
Re:having grub load with different virtual address?
Posted: Sun Mar 21, 2004 4:56 am
by bkilgore
Did you follow the code listing 11 sample closely? You have to make sure you specify both the virtual address and the physical address.
Code: Select all
OUTPUT_FORMAT("elf32-i386")
ENTRY(entry)
virt = 0xC0000000; /* 3 gig */
phys = 0x100000; /* 1 meg */
SECTIONS
{ .text virt : AT(phys)
{ code = .;
*(.text)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{ data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{ bss = .;
*(.bss)
*(COMMON)
. = ALIGN(4096);
}
end = .;
}
Make sure you have the line
that specifies that you want the virtual address to be 'virt' (or 0xC0000000) but the physical address to load to to be 'phys' (or 0x100000). Grub doesn't have anything to do with the virtual address, that should all be handled by your kernel while initially mapping your kernel into the virtual address space. Grub only takes the physical address from the .elf file and loads the code there.
Re:having grub load with different virtual address?
Posted: Sun Mar 21, 2004 9:55 pm
by proxy
yea, i noticed i originally had a typo in my link script, it now loads
Next step I have to have my initial setup code provide enough of a GDT to make the system think 0xc0000000 is 1 MEG

while i setup the rest of the system i suppose
proxy