I've been working on porting my kernel (which is still in very early stages), to 64bit so that I don't have to go through all the trouble later. I've been succesfull in getting it to switch from 32 to 64 (running from higher half), and running my c/c++ code. However, when I try to link crtbegin.o and crtend.o into the kernel, to get the global constructors working, I get linker errors.
They are being caused by the higher half kernel, but I don't know how to solve it.
The command used to link:
Code: Select all
/home/rob/opt/cross/bin/x86_64-elf-g++ -T linker.ld -nostdlib -ffreestanding -z max-page-size=0x1000 -g -ggdb -o bin/kernel src/bootstrap.o src/start64.o src/crti.o /home/rob/opt/cross/lib/gcc/x86_64-elf/4.9.0/crtbegin.o src/main.o /home/rob/opt/cross/lib/gcc/x86_64-elf/4.9.0/crtend.o src/crtn.o -lgcc
Code: Select all
/home/rob/opt/cross/lib/gcc/x86_64-elf/4.9.0/crtbegin.o: In function `deregister_tm_clones':
crtstuff.c:(.text+0x1): relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__' defined in .jcr section in bin/kernel
crtstuff.c:(.text+0x8): relocation truncated to fit: R_X86_64_32S against `.tm_clone_table'
crtstuff.c:(.text+0x21): relocation truncated to fit: R_X86_64_32 against `.tm_clone_table'
/home/rob/opt/cross/lib/gcc/x86_64-elf/4.9.0/crtbegin.o: In function `register_tm_clones':
crtstuff.c:(.text+0x41): relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__' defined in .jcr section in bin/kernel
crtstuff.c:(.text+0x49): relocation truncated to fit: R_X86_64_32S against `.tm_clone_table'
crtstuff.c:(.text+0x6f): relocation truncated to fit: R_X86_64_32 against `.tm_clone_table'
/home/rob/opt/cross/lib/gcc/x86_64-elf/4.9.0/crtbegin.o: In function `__do_global_dtors_aux':
crtstuff.c:(.text+0x8f): relocation truncated to fit: R_X86_64_32 against symbol `__DTOR_END__' defined in .dtors section in /home/rob/opt/cross/lib/gcc/x86_64-elf/4.9.0/crtend.o
crtstuff.c:(.text+0x96): relocation truncated to fit: R_X86_64_32S against `.dtors'
crtstuff.c:(.text+0xc6): relocation truncated to fit: R_X86_64_32S against `.dtors'
crtstuff.c:(.text+0xe6): relocation truncated to fit: R_X86_64_32 against `.eh_frame'
crtstuff.c:(.text+0xeb): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Code: Select all
kernel_VMA = 0xffff800000000000;
kernel_LMA = 0x100000;
/* start from the entry point */
ENTRY(_bootstrap)
SECTIONS
{
. = kernel_LMA;
.text_boot :
{
src/bootstrap.o (.text)
}
. = . + kernel_VMA;
.text : AT(ADDR(.text) - kernel_VMA + kernel_LMA)
{
code = .;
*(.text)
*(.text*)
/* read only data */
*(.rodata*)
*(.rdata*)
. = ALIGN(4096);
}
.data : AT(ADDR(.data) - kernel_VMA + kernel_LMA)
{
data = .;
*(.data)
. = ALIGN(4096);
}
_end_data = .;
.bss : AT(ADDR(.bss) - kernel_VMA + kernel_LMA)
{
*(.bss)
. = ALIGN(4096);
}
.ehframe : AT(ADDR(.ehframe) - kernel_VMA + kernel_LMA)
{
ehframe = .;
*(.ehframe)
. = ALIGN(4096);
}
_end = .;
}
Does anyone have an idea how to solve this?
Thank you in advance,
Rob