我是一个汇编语言新手,这是我的小程序。
section .data
section .text
global _start
_start:
nop ; make gdb happy
; put your experiments here
mov eax,4
; put your expeirments here
nop ; make gdb happy
section .bss这段代码是用以下命令编译的:
nasm -f elf64 -g -F stabs 001.asm -o 001.o
ld -o test 001.o但是当我运行时,它会生成一个具有段错误的核心转储文件。
1.为什么这个小程序有段错误?
2.如何使用核心转储文件对此进行gdb?在这里输入图像描述
发布于 2017-03-17 11:19:38
您的程序不包含结束它的代码。在执行代码中的最终nop之后,CPU将继续执行所包含的内存,直到它崩溃为止。若要解决此问题,请通知操作系统终止您的进程。在amd64 Linux上,您可以使用以下代码:
mov eax,60 ; system call 60: exit
xor edi,edi ; set exit status to zero
syscall ; call the operating systemhttps://stackoverflow.com/questions/42856035
复制相似问题