DJGPP linker issue?
Posted: Thu Dec 16, 2004 11:57 am
Hey guys!
I hope you can give me a little help here with this!
I use GRUB that doesn't allow me to load a kernel below 1 MB; solution is to set my text segment to start at 1 MB (0x100000), right? (linker script below).
I also use NASM to compile my boot.asm file. This file sets GDT and IDT properly and enters protected mode. But NASM won't mix 16- and 32-bit code; solution is to use the a.out format, right? So I mix 16- and 32-bit in one single file.
I also use DJGPP linker that is able to link the a.out format but here the problem comes in :
I got "relocation truncated to fit: 16 text" when linking the boot.asm with my kernel.o objects because no 16-bit object can be at an offset > 0xFFFF and my linker script sets text segment to 0x100000 and I can't set this value below because GRUB won't load my kernel.
I would like to know where I'm doing mistakes when implementing the OS. I'm wondering if I really have to use different VMA and LMA addresses in the linker script and if this will work or not.
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x100000 : {
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data : {
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Thanks to all.
Luis
I hope you can give me a little help here with this!
I use GRUB that doesn't allow me to load a kernel below 1 MB; solution is to set my text segment to start at 1 MB (0x100000), right? (linker script below).
I also use NASM to compile my boot.asm file. This file sets GDT and IDT properly and enters protected mode. But NASM won't mix 16- and 32-bit code; solution is to use the a.out format, right? So I mix 16- and 32-bit in one single file.
I also use DJGPP linker that is able to link the a.out format but here the problem comes in :
I got "relocation truncated to fit: 16 text" when linking the boot.asm with my kernel.o objects because no 16-bit object can be at an offset > 0xFFFF and my linker script sets text segment to 0x100000 and I can't set this value below because GRUB won't load my kernel.
I would like to know where I'm doing mistakes when implementing the OS. I'm wondering if I really have to use different VMA and LMA addresses in the linker script and if this will work or not.
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x100000 : {
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data : {
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Thanks to all.
Luis