我是新手,所以我的表达方式可能不准确。我需要使用汇编程序在 C 中进行系统调用“execve”。我不使用任何库。不起作用的部分是
char *nul=(char *)0;
char *argv[] = { "/bin/date", nul };
char *envp[] = { nul };
long ret;
asm volatile ("int $0x80" : "=a" (ret) : "a" (11), "b" (argv[0]), "c" (argv), "d" (envp));
//"a" (11) ... 11 correspondes to execve
我编译代码(既没有错误也没有警告)
gcc -m32 -nostdlib -nostdinc -static -O2 sysc.c -o sysc
当我尝试运行该程序时,我看到此消息:
A NULL argv[0] was passed through an exec system call.
Aborted