output from emerge is attached.
Created attachment 3383 [details] output from emerge libgd
ln -s /lib/libm-2.2.5.so /usr/lib/libm.so solved the issue. Seems to be a bug in glibc