Search code examples
assemblyx86x86-64nasmyasm

Debugging assembly code created with yasm


I need some help finding and using a good debugger for asm code assembled with yasm on 64-bit Linux. The gdb debugger keeps complaining that no symbol tables are loaded. Someone on stackoverflow suggested assembling with the -dstabs switch, but that makes no difference for me. Neither does ddd make a difference.

gdb wouldn't be so bad if I could find a way to get rid of the "no symbol tables loaded" problem. I also need to be able to view the contents of registers and other declarations.

I assemble my asm files using yasm -f elf -m amd64 file.asm and I link with ld file.o -o file. Creating a .lst file with yasm using the -l switch doesn't seem to work either.

All the advice I've found regarding this matter seem to be related to using gcc as a linker and not ld. I need to be able to link with ld.


Solution

  • You should use the -g option to yasm. I'd suggest using the dwarf2 format as that seems to be the standard nowadays.

    yasm -f elf -m amd64 -g dwarf2 file.asm