Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6334

"relocation truncated to fit" errors with ld when trying to link asm cand c++ files

$
0
0

Hello I am trying to link several files together for the use of building a kernel. For the boot code I am using nasm to assemble to a .o file using the following command nasm -f elf64 src/impl/x86_64/boot/%%f -o build/x86_64/boot/!sub! in this %%f is set to a assembly file within the src/impl/x86_64/boot/ directory and sub is that same file but the .asm is changed to a .o and it is saved to the build/x86_64/boot/ directory. for the actual kernel files I am using c++ and assembling using g++ -c -ffreestanding src/impl/kernal/%%f -o build/kernal/!sub! where %%f is set to a .cpp file within the src/impl/kernal directory and sub is set to the same file but the .cpp is changed to a .o and it is saved to the build/kernal/ directory. These 2 commands work fine without errors and produce expected results. The error comes when linking. To link these files together I am using the following command ld -n -o dist/x86_64/kernel.bin -T targets/x86_64/linker.ld build/kernal/*.o build/x86_64/boot/*.o with linker.ld set to

ENTRY(start)SECTIONS{    . = 1M;    .boot :    {        KEEP(*(.multiboot_header))    }    .text :    {        *(.text)    }}

However this throws several errors all something along the lines of build/kernal/mainc.o:mainc.cpp:(.pdata+0x0): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against `.text' So far nothing I have found has seemed to work out. Does anyone know how I could solve these errors


Viewing all articles
Browse latest Browse all 6334

Trending Articles