kar*_*lip 2 linux assembly gnu shutdown segmentation-fault
以下应用程序在执行时会生成分段错误:
.set __NR_reboot, 169
.set LINUX_REBOOT_CMD_POWER_OFF, 0x4321FEDC
.section .text
.globl _start
_start:
movl $LINUX_REBOOT_CMD_POWER_OFF, %ebx
movl $__NR_reboot, %eax
int $0x80
Run Code Online (Sandbox Code Playgroud)
这是一个非常简单的应用程序,我必须遗漏一些非常明显的东西.有人能帮我吗?
它编译为:
as shutdown.s -o shutdown.o
ld shutdown.o -o shutdown
Run Code Online (Sandbox Code Playgroud)
编辑:
即使只是调用syscall sync()的简单应用程序也会生成分段错误:
.set __NR_sync, 36
.section .text
.globl _start
_start:
movl $__NR_sync, %eax
int $0x80
movl $1, %eax #syscall exit
movl $0, %eax
int $0x80
Run Code Online (Sandbox Code Playgroud)