Segmentation Fault when shutting down Linux with assembly application -


the following application generates segmentation fault when executed:

.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 

it's quite simple application , must missing obvious. can me?

it compiled with:

as shutdown.s -o shutdown.o ld shutdown.o -o shutdown 

edit:

even simple application calls syscall sync() generates segmentation fault:

.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 

warning: remember sync(2) before calling reboot(2).

the reboot(2) system call takes 4 parameters.you confusing libc wrapper.

warning: remember sync(2) before calling reboot(2).

(it takes magic* parameters people have reread documentation , don't forget calling sync(2).)

warning: did have sync(2) before calling reboot(2)?


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -