我在ASM(NASM)中有一个程序,我想获取一个地址,但是当我使用GDB进行调试时(我输入“next”并退出程序)会发生一些奇怪的错误。 GDB中是否有一些错误?
TEST.ASM
BITS 32
section .text
global _start
_start:
call function
mov eax,0x41414141
function:
# esi get the address of "mov eax,0x41414141"
pop esi
# Exit
xor eax,eax
xor ebx,ebx
mov al,0x01
int 0x80
调试
$ nasm -f elf test.asm
$ ld test.o -o test
$ gdb -q ./test
Reading symbols from /root/Desktop/test...(no debugging symbols found)...done.
(gdb) info functions
All defined functions:
Non-debugging symbols:
0x08048060 _start
0x0804806a function
(gdb) b function
Breakpoint 1 at 0x804806a
(gdb) run # Execute _start
Starting program: /root/Desktop/test
Breakpoint 1, 0x0804806a in function ()
(gdb) # We're going to execute "pop esi" now
(gdb) next # Execute only 1 instruction
Single stepping until exit from function function,
which has no line number information.
[Inferior 1 (process 26492) exited normally]
# WHY EXIT? We was going to execute "pop esi" !!
答案 0 :(得分:2)
您使用" next"告诉gdb做源级步骤(移动到源中的下一行)。由于您没有使用调试信息构建可执行文件,因此gdb不知道如何执行此操作。 有两种解决方案: