rtld: Make thread-safe by replacing libc printf functions
authorJohn Marino <draco@marino.st>
Sat, 21 Jan 2012 15:07:30 +0000 (16:07 +0100)
committerJohn Marino <draco@marino.st>
Mon, 23 Jan 2012 16:13:17 +0000 (17:13 +0100)
commitabfcd5b1045e58aecb0f84d4e269d0d1b3b20d6e
tree2ed1bb6201b4fd7198d031c0fe705f0e5c38032a
parentb566341b03125971f3394e8c877fba725175ce1f
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
libexec/rtld-elf/Makefile
libexec/rtld-elf/debug.c
libexec/rtld-elf/malloc.c
libexec/rtld-elf/rtld.c
libexec/rtld-elf/rtld.h
libexec/rtld-elf/rtld_lock.c
libexec/rtld-elf/rtld_printf.c [new file with mode: 0644]
libexec/rtld-elf/rtld_printf.h [copied from libexec/rtld-elf/xmalloc.c with 67% similarity]
libexec/rtld-elf/xmalloc.c