如何用nasm生成gdb符号文件? [英] How to generate gdb symbol file with nasm?

查看:428
本文介绍了如何用nasm生成gdb符号文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个用汇编编写的玩具启动程序/内核,并在qemu模拟器上运行。我可以使用 -s -S 选项运行qemu并使用远程目标进行gdb调试,但是我没有使用gdb加载任何调试符号。如何从我的程序集生成符号文件?



我使用nasm生成qemu的二进制映像以从我的程序集文件运行,但我没有无论如何发现调试信息在图像本身(我不知道这是否有意义)。我还发现gdb允许你加载一个单独的符号文件进行调试,所以现在我的问题是如何从我的汇编代码生成符号文件。



我已经看到了使用 objcopy 的建议,但我相信只适用于elf文件,而不是二进制文件。我已经尝试过让nasm生成一个精灵,但是因为我的(必要的) org 伪指令在程序集文件中,所以它一直在进行barfing。

解决方案

它会说这样试试:
1)组装时使用-f elf -F dwarf -g开关。这应该产生包含调试符号(以及代码和其他所有内容)的elf文件。
2)使用objcopy生成二进制文件。
3)将二进制文件加载到您的系统。
4)附加调试器,然后告诉它从您的.elf文件中加载符号(symbol-file yourfile.elf)

您需要解决为什么nasm可以不会生成自己的.org文件。我不知道。 GNA一样好。


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.

解决方案

It would say try it like this: 1) use "-f elf -F dwarf -g" switches when assembling. This should produce elf file that contains debug symbols (and code and everything else). 2) Use objcopy to generate binary file. 3) Load binary file to your system. 4) Attach debugger, then tell it to load symbols from your .elf file (symbol-file yourfile.elf)

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.

这篇关于如何用nasm生成gdb符号文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆