我无法运行以下C代码:
#include <sys/syscall.h>
#include <sys/types.h>
#define NULL ((void*)0)
int syscall3 (int code, int arg1, char* arg2, int arg3);
int syscall1 (int code, int arg);
int _start() {
char ptr[14] = "Hello sysprog";
syscall3(SYS_write, 0, ptr, 14);
syscall1(SYS_exit, 0);
return 0;
}
int syscall3 (int code, int arg1, char* arg2, int arg3) {
asm volatile("int $0x80": "=a" (code) : "a" (code), "b" (arg1), "c" (arg2), "d" (arg3));
return code;
}
int syscall1 (int code, int arg) {
asm volatile("int $0x80": "=a" (code) : "a" (code));
return code;
}
我尝试使用-nostdlib
和-nostartfiles
gcc选项进行编译,但它不起作用。
运行该代码需要做什么?