【发布时间】:2019-07-27 15:09:19
【问题描述】:
我在 win10 64 位家庭主机上运行一个虚拟机。在虚拟机上我安装了 ubuntu 18.04 64 位。
我从网站下载了一个示例汇编程序,与我从“Assembly language step-by-step”学习的书相关。
这是程序:
; vim: ft=nasm
;
; Build using these commands (works on 32-bit Linux)
; nasm -f elf -g -F stabs eatsyscall.asm
; ld -o eatsyscall eatsyscall.o
;
; Build on 64-bit Linux: (Linux 3.13.7-1-ARCH #1 x86_64 GNU/Linux)
; nasm -f elf64 -g -F stabs eatsyscall.asm
; ld -o eatsyscall eatsyscall.o
;
; Build on OSX (although the instructions are not valid for its architecture)
; nasm -f macho eatsyscall.asm
; ld -arch i386 -macosx_version_min 10.5 -no_pie -e _start -o eatsyscall eatsyscall.o
;
section .data ; contains initialized data
EatMsg: db "Eat at Joe's!",10
EatLen equ $ - EatMsg
section .bss ; contains uninitialized data
section .text ; contains code
global _start ; entry point found by linker (default is _start)
_start:
nop ; needed to allow debugging with gdb - lldb not properly working ATM
mov eax,4 ; Specify sys_write syscall
mov ebx,1 ; specify file descriptor: stdout
mov ecx,EatMsg ; pass message offset
mov edx,EatLen ; pass message length
int 80H ; make syscall to output text to stdout
mov eax,1 ; specify exit syscall
mov ebx,0 ; return code of zero
int 80H ; make syscall to terminate program
当我尝试使用 kdbg 或直接使用 gdb 进行调试时,同样会发生 2 件奇怪的事情(对我来说很奇怪,但可能只是我完全没有经验):
当我尝试在第 29 行“mov eax, 4”处设置断点时 - 调试器并不止于此。只有当我从上述行开始一个接一个地放置 3 个断点时,它才会停止。
当调试器停止时,如果我尝试执行单步执行命令,调试器会告诉我程序以“SIGSEGV”信号终止 - 分段错误。调试程序没有终止,但我正在尝试调试的程序。
我尝试在网上搜索此内容,但找不到与我遇到的问题相关的任何内容。
我们将不胜感激。
【问题讨论】:
标签: linux assembly x86-64 nasm