无法找到入口点_start GCC

时间:2017-07-30 07:17:51

标签: c gcc main entry-point

我无法运行以下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选项进行编译,但它不起作用。

运行该代码需要做什么?

0 个答案:

没有答案