Reputation: 143
I am building a small OS exectuable and i have issues with the linking process using NASM, GCC and GNU Binutils.
I am linking multiple types of object files:
When I link toghether these files with a custom linker script and then re-read the degub information, I only find the debug info from the first object file linked (ordered by effective address).
For reference purposes, I'll post a couple of the lines that i use to compile:
nasm -g -felf32 -F dwarf entry.asm -o "build/entry.o"
gcc -c main.c -o "build/main.o" -m32 -mtune=i386 -gdwarf
And link:
ld -Tlinker.ld -m elf_i386 --nmagic -nostdlib -static -o "build/bootload.elf" -M -g > "build/map.txt"
I Use GCC v. 6.2, Binutils v. 2.27 and NASM v. 2.12
I'll post bits of the linker script if needed. Please help, debugging without line information is very annoying.
Upvotes: 0
Views: 322
Reputation: 143
Fixed.
The problem, as suggested by @Jester(thanks), was in the linker script.
I was putting every object file section inside the .text
section of the final ELF file. I'll post some code to explain the old and new, corrected behaviour:
OLD:
.text : AT(0x800) {
test.o(*);
}
NEW:
.text : AT(0x800) {
test.o(.text);
test.o(.data);
test.o(.bss);
}
All this code is for the linker script.
Upvotes: 1