feel free to email me at

Libc usage

On my debian/sarge system with stock libc and php:

kef@flash:~$ nm --defined-only /usr/lib/libc.a|awk '$2 == "T" {print $3;}'|grep -v '^_' > libc.symbols
kef@flash:~$ objdump -R `which php` | awk '{print $3;}' > php4.symbols
kef@flash:~$ cat php4.symbols| while read f; do if grep -q "^$f$" libc.symbols; then echo "$f"; fi; done > php4-libc
kef@flash:~$ wc -l *
  758 libc.symbols
   97 php4-libc
  866 php4.symbols
 1721 total
kef@flash:~$ php -r 'echo 97/758 . "\n";'
0.127968337731

PHP4 uses only tenth (97) of 758 functions libc provides.

kef@flash:~$ cat php4-libc|while read f; do echo "$f `man -S 2:3 -w "$f"`"; done|grep man2|wc -l
22
kef@flash:~$ php -r 'echo 22/97 . "\n";'
0.226804123711

22 of overall 97 are just wrappers for kernel syscalls.

kef@flash:~$ mkdir x; cd x; ar x /usr/lib/libc.a; cd ..
kef@flash:~$ cat php4-libc|while read f; do test -e "/usr/share/man/man3/$f.3.gz" && echo "$f" $((0x`objdump -h "x/$(nm --defined-only /usr/lib/libc.a -A 2>/dev/null |grep "T $f\$"|cut -d: -f2)" |grep text | awk '{print $3}'`)); done | awk '{sum+=$2} END {print sum}'
66161

Other 75 functions weight 64kb.

kef@flash:~$ ls -lh /lib/libc-2.3.2.so
-rwxr-xr-x  1 root root 1.2M Apr  2  2006 /lib/libc-2.3.2.so

Do we realy need this 1.2M?