rtld: Make thread-safe by replacing libc printf functions
The dynamic linker is linked with the specially built static pic libc to
get some C runtime services such as printf(). Unfortunately, the
multithread-safeness measures in libc do now work in the rtld environment.
The dynlinker now uses FreeBSD's kernel printf() implementation instead of
libc's version. This printf does not require any shared global data and
thus is mt-safe. This commit replaces printf() and related functions with
rtld_ versions, and also removes calls to err(3).
Currently stdio is still pulled from libc within the libmap implementation
that uses fopen(). This is safe, yet not optimal, and is a candidate for
future change.
The makefile was cleaned up to remove the unused bits to building an
executable dynlinker and also require gnu99.
Taken-from: FreeBSD SVN 225152