In said:
1900 bytes just to make two system calls?
It could be made much smaller
The size of the smallest C program is determined by the size of the
startup module:
fangorn:~/tmp 110> cat test.c
int main(void)
{
return 0;
}
fangorn:~/tmp 111> gcc -s test.c
fangorn:~/tmp 112> ls -l a.out
-rwxr-xr-x 1 danpop sysprog 2912 Jan 19 15:50 a.out*
If I want to get a smaller binary, that still works, I have to start
cheating:
fangorn:~/tmp 123> cat cheat.c
int main()
{
_exit(0);
}
fangorn:~/tmp 124> gcc -s -static -nostdlib cheat.c -lc
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 08048080
fangorn:~/tmp 125> ls -l a.out
-rwxr-xr-x 1 danpop sysprog 740 Jan 19 15:56 a.out*
fangorn:~/tmp 126> ./a.out
fangorn:~/tmp 127> echo $status
0
The ld warning was caused by the missing startup module, but this
minimal program doesn't really need it. The first program above, however,
does:
fangorn:~/tmp 128> gcc -s -static -nostdlib test.c -lc
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 08048080
fangorn:~/tmp 129> ./a.out
Segmentation fault
fangorn:~/tmp 130> ls -l a.out
-rwxr-xr-x 1 danpop sysprog 588 Jan 19 16:00 a.out*
The missing syscall support from the statically linked executable
made it both shorter and non-functional.
Dan