> portable
> #define _GNU_SOURCE
If it's portable, what's the point of defining _GNU_SOURCE? Honest question.
> #define _GNU_SOURCE
If it's portable, what's the point of defining _GNU_SOURCE? Honest question.
_GNU_SOURCE is requested by man 2 syscall. Interestingly it mentions it appeared in 4BSD, so possibly it might work (maybe with some changes) under other Unixy platforms.
$ gcc -nostartfiles a.c -o a -Wl,--entry=_start -static
$ ./a
-bash: ./a: cannot execute binary file: Exec format error
$ file a
a: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped\
But the final binary is impressively small, and it seem to contain all relevant code (body of _start and syscall funcs) $ strip -s a; ls -l a
-rwxr-xr-x 1 user users 2688 Jan 5 07:53 a
Works under FreeBSD though: $ clang -nostartfiles a.c -o a -static
$ ./a
Hello world!
$ strip -s a; ls -l a
-rwxr-xr-x 1 user user 9216 Jan 5 07:59 a