GLIBC なしでコンパイルするときに main() から値を返そうとしていますが、機能しません。インターネットで見つけたこの例を見てみましょう:
[niko@localhost tests]$ cat stubstart.S
.globl _start
_start:
call main
movl $1, %eax
xorl %ebx, %ebx
int $0x80
[niko@localhost tests]$ cat m.c
int main(int argc,char **argv) {
return(90);
}
[niko@localhost tests]$ gcc -nostdlib stubstart.S -o m m.c
[niko@localhost tests]$ ./m
[niko@localhost tests]$ echo $?
0
[niko@localhost tests]$
ここで、GLIBC でコンパイルすると、戻り値が正常に取得されます。
[niko@localhost tests]$ gcc -o mglibc m.c
[niko@localhost tests]$ ./mglibc
[niko@localhost tests]$ echo $?
90
[niko@localhost tests]$
どうやら stubstart.S で正しく返されていません。どうすれば正しくなりますか? (Linux のみ)