Your syscall numbers seem WAY off.
From your use of movq
and the "r" registers, I can guess you are trying on x86-64. Taking a look at /usr/include/asm/unistd_64.h
, I can see the following:
#define __NR_write 1
#define __NR_stat 4
#define __NR_exit 60
strace
agrees with me:
$ strace ./abc
execve("./abc", ["./abc"], [/* 43 vars */]) = 0
stat("", NULL) = -1 EFAULT (Bad address)
write(-1698988341, NULL, 3 <unfinished ... exit status 0>
Note that the parameters are also way off. You are also using the wrong registers for the rest of the parameters. The calling convention on x86-64, AFAIK, uses the following registers for the parameters, in this order: rdi
, rsi
, rdx
, r10
, r8
, r9
.
Perhaps you are trying to do syscalls on x86-64 the way they are done on i386 and expecting it to be the same?