assembly - NASM 中的调试符号(再一次)
问题描述
这个问题已经在 StackOverflow 上被问过好几次了,但我尝试了所有的答案,但我仍然无法让 NASM 包含 DWARF 调试符号。
我在 Ubuntu 18.04 64 位下使用 NASM 2.13.02。我不确定我是否还缺少某些东西?
万一这很重要,我实际上想同时使用 LLDB 和 GDB。
谢谢。
这是我的代码:
section .bss
section .text
global _start
_start:
mov ebx, 0
mov eax, 1
int 80h
这是我构建和链接它的方式:
nasm -g -F dwarf -f elf64 hello.asm
ld -s -o hello hello.o
结果文件是:
$ ls -la hello
-rwxr-xr-x 1 terry terry 352 Sep 4 18:21 hello
$
尝试检查是否包含 DWARF 数据:
$ dwarfdump hello
No DWARF information present in hello
$
在 gdb 下运行:
$ gdb ./hello
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
[... snip copyright ...]
Reading symbols from ./hello...(no debugging symbols found)...done.
(gdb)
解决方案
我根据@Michael Petch 的建议自我回答我自己的问题,他是真正找到根本原因的人。
问题是我使用ld
的-s
意思是“全部剥离”,包括调试符号,即我正在破坏自己的努力。
正确的命令应该是:
nasm -g -F dwarf -f elf64 hello.asm
ld -o hello hello.o
现在,使用 gdb:
$ gdb ./hello
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
[.. snip copyright ..]
Reading symbols from ./hello...done.
(gdb) b _start
Breakpoint 1 at 0x400080: file hello.asm, line 7.
(gdb) run
Starting program: /home/terry/hello
Breakpoint 1, _start () at hello.asm:7
7 xor ebx, 0
(gdb)
$
推荐阅读
- c# - WordAddIn 获取文档句柄
- javascript - 无法使用 axios 获取linkedin 的访问令牌
- azure-functions - Azure 功能快速扩展超过 200 个实例
- html - HTML 和 CSS - 我无法删除边距
- npm - 在我的 windows10 上安装 create-react-app 的问题
- nginx - K8S Ingress 404 ssl 后端
- node.js - 添加 express-flash 中间件后 Express 服务器无法正常工作
- kubernetes - Kubernetes:打开/certs/tls.crt:没有这样的文件或目录
- javascript - 为什么 Web API 在 chrome 和 edge 等浏览器以及 Postman 工具中没有给出 CORS 错误?
- javascript - 错误 #98123:运行“gatsby develop”命令后,WEBPACK 未绑定 CSS