I'm working on a toy bootloader/kernel written in assembly and run on the qemu emulator. I can run qemu with -s -S
option and debug with gdb using remote target, but I don't have any debug symbols loaded with gdb. How can I generate a symbol file from my assembly?
I'm using nasm to generate a binary image for qemu to run from my assembly file, but I haven't found anyway to include debug information in the image itself (I'm not sure if that even makes sense). I also found that gdb allows you to load an separate symbol file for debugging, so now my issue is how to generate a symbol file from my assembly code.
I've seen suggestions to use objcopy
, but I believe that only works on elf files, not binary. I've tried getting nasm to generate an elf, but it keeps barfing because of my (necessary) org
directive in the assembly file.
Use your favorite editor to create a nasm assembly language file. e.g. hello.asm shown below. Type the command: nasm -f elf -l hello.lst hello.asm If your program had no assembly time errors, nothing displays. If you had assembly time errors, fix them and repeat the command.
If you would like to see all the different output formats that Nasm can produce, run the following command at your terminal prompt: Meanwhile, there are two fixes I've found that work for people using 64-bit machines. First, to produce a native 64-bit object module and executable, simply change elf to elf64 in Jeff's command, like so:
Now you need to insert NASM in the development environment MinGW. Unpack the NASM archive. You should get a folder containing, among other things, a file named nasm.exe. Copy this file into the directory C: \ MinGW \ bin.
Netwide Assembler (NASM) is an assembler and dissembler for the Intel x86 architecture and is commonly used to create 16-bit, 32-bit (IA-32), and 64-bit (x86-64) programs. How to compile an assembly program with NASM for Linux? You can use any text editor, such as Gedit, KWrite, or XEmacs, to do so.
It would say try it like this:
You need to solve why nasm can't generate .elf file with .org you have in there. I have no idea. GNA as is fine with this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With