How to create a gdb symbol file with nasm?

I am working on a bootloader / kernel written in an assembly and running on the qemu emulator. I can run qemu with the -s -S and debug with gdb using the remote target, but I don't have any debug symbols loaded with gdb. How can I generate a character file from my assembly?

I use nasm to create a binary image for qemu to run from my build file, but I still could not find debugging information in the image itself (I'm not sure if that even makes sense). I also found that gdb allows you to load a separate symbol file for debugging, so now my problem is how to generate the symbol file from my assembly code.

I saw suggestions to use objcopy , but I believe that it only works with elf files, not binary ones. I tried to get nasm to generate an elf, but it saves barfing due to my (necessary) org directive in the build file.

+4
source share
1 answer

You could say, try it like this: 1) use the -f elf -F dwarf -g switches when building. This should create an elf file containing debugging symbols (and code and everything else). 2) Use objcopy to generate the binary. 3) Download the binary file to your system. 4) Attach the debugger, then tell it to load the symbols from your .elf file (symbol-file yourfile.elf)

You need to decide why nasm cannot generate the .elf file from the .org that you have. I have no idea. GNA as well with that.

+4
source

Source: https://habr.com/ru/post/1488727/


All Articles