【发布时间】:2014-01-14 17:15:08
【问题描述】:
对于我的问题,当我尝试在 ubuntu 64 位版本下创建 NASM 示例并在组装并链接到 ELF 后执行它。当我执行时它返回如下错误消息
NASM -f elf64 -o firstasm.o firstasm.asm ld -o firstasm firstasm.o 第一手
分段错误(核心转储)
我的 NASM 代码将低于我尝试执行简单 write() 和 exit() 函数的位置
section .data ;Data segment
msg db "This line is test", 0x0a
section .text ;text segment
global _start ;Default entry point for ELF linking
_start:
; SYSCALL : write (1,msg,14)
xor rax,rax
xor rbx,rbx
xor rcx,rcx
xor rdx,rdx
mov rax,64 ; make a syscall write 4
mov rbx,1 ; put 1 into rbx and also stdout is 1
mov rcx,msg ;put address of string in rcx
mov rdx,19 ; put length of string into rdx
int 0x80 ; call kernel to made syscall
; SYSCALL : exit(0)
xor rax,rax
xor rbx,rbx
mov rax,93 ; make a syscall exit 93
mov rbx, 0 ; store 0 argument into rbx, success to exit
int 0x80
有人可以指出我的 NASM 代码有什么问题,并提出解决“分段错误(核心转储)”问题的建议。感谢任何可以提供帮助的人。
【问题讨论】: