Page 1 of 1
GDB Qemu debugging symbols
Posted: Thu Jun 19, 2014 4:09 pm
by therll
My kernel compiles correctly in debug mode using
Code: Select all
i686-elf-gcc -g -T link.ld -o myos.bin -ffreestanding -O2 -nostdlib start.o main.o scrn.o gdt.o idt.o isrs.o irq.o timer.o kb.o
and boots in Qemu. However when I debug using GDB through
, loading my bin file as the GDB symbol file returns an error:
Code: Select all
can't read symbols: File format not recognized.
I'm following
http://wiki.osdev.org/Kernel_Debugging# ... _with_Qemu and I think the problem might be that my kernel isn't an elf file but I'm not sure how to make it an elf file or extract the symbols from this binary file. What am I doing wrong?
Re: GDB Qemu debugging symbols
Posted: Thu Jun 19, 2014 4:18 pm
by turboscrew
If you first produce an ELF then make bin from it, load the bin into the qemu, but the ELF in gdb before the "target remote"-command.
Re: GDB Qemu debugging symbols
Posted: Thu Jun 19, 2014 4:36 pm
by therll
But how do I produce one big ELF from all the little compiled .o ELF files?
Re: GDB Qemu debugging symbols
Posted: Thu Jun 19, 2014 4:44 pm
by therll
Ok I figured it out
lists the available formats and the .ld linker script has an OUTPUT_FORMAT property which can be changed to elf32-i386 and then the symbols load just fine!
Re: GDB Qemu debugging symbols
Posted: Fri Jun 20, 2014 12:59 am
by max
therll wrote:Code: Select all
can't read symbols: File format not recognized.
I'm following
http://wiki.osdev.org/Kernel_Debugging# ... _with_Qemu and I think the problem might be that my kernel isn't an elf file but I'm not sure how to make it an elf file or extract the symbols from this binary file. What am I doing wrong?
You must make sure that GDB understands the object format for your target platform. You can simply compile GDB from sources to get one specific for your target platform by doing the same as when you compiled your cross compiler (by adding the "--target" flag to configure).
EDIT: therll wrote:lists the available formats and the .ld linker script has an OUTPUT_FORMAT property which can be changed to elf32-i386 and then the symbols load just fine!
I don't think that you really want that. You made a cross-compiler that compiles binaries for i686, and now you're linking them as i386? That's why you should make a cross-gdb (as described above), because it is able to read your target platforms object format.
Re: GDB Qemu debugging symbols
Posted: Sun Jun 22, 2014 10:24 pm
by turboscrew
If there is i686-elf-gcc, there is probably i686-elf-objdump too?