如何在 Mac OS X 上构建包含入口点的 C 程序?
我想建立:
start() {
/* exit system call */
asm("movl $1,%eax;"
"xorl %ebx,%ebx;"
"int $0x80"
);
}
但是当我运行时:
gcc -nostdlib min.c
我总是得到:
ld: could not find entry point "start" (perhaps missing crt1.o)
collect2: ld returned 1 exit status
我进行的另一次尝试只是为了看看它在做什么:
gcc -nostdlib -c min.c && otool -tV min.o
输出是:
(__TEXT,__text) section
_start:
0000000000000000 pushq %rbp
0000000000000001 movq %rsp,%rbp
0000000000000004 leave
0000000000000005 ret
那么在“开始”功能之前,下划线是从哪里来的呢?我该如何防止这种情况发生?或者更简单地说:
如何在 Mac OS X 上构建包含入口点的 C 程序?
谢谢, CrazyChenz