使用程序集应用程序关闭Linux时出现分段错误

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)

nin*_*alj 5

警告:sync(2)在打电话之前记得reboot(2).

reboot(2)系统调用需要4个parameters.You与libc的包装迷惑了.

警告:sync(2)在打电话之前记得reboot(2).

(它实际上需要魔术*参数,以便人们必须重新阅读文档,不要忘记调用sync(2).)

警告:sync(2)在打电话之前我说过你必须这么做reboot(2)吗?