git: rtld: Make thread-safe by replacing libc printf functions

John Marino marino at crater.dragonflybsd.org
Mon Jan 23 08:15:10 PST 2012


commit abfcd5b1045e58aecb0f84d4e269d0d1b3b20d6e
Author: John Marino <draco at marino.st>
Date:   Sat Jan 21 16:07:30 2012 +0100

    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

Summary of changes:
 libexec/rtld-elf/Makefile      |   18 +-
 libexec/rtld-elf/debug.c       |   24 +-
 libexec/rtld-elf/malloc.c      |   26 +--
 libexec/rtld-elf/rtld.c        |   27 ++-
 libexec/rtld-elf/rtld.h        |    1 +
 libexec/rtld-elf/rtld_lock.c   |    2 -
 libexec/rtld-elf/rtld_printf.c |  487 ++++++++++++++++++++++++++++++++++++++++
 libexec/rtld-elf/rtld_printf.h |   44 ++++
 libexec/rtld-elf/xmalloc.c     |   16 +-
 9 files changed, 580 insertions(+), 65 deletions(-)
 create mode 100644 libexec/rtld-elf/rtld_printf.c
 create mode 100644 libexec/rtld-elf/rtld_printf.h

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/abfcd5b1045e58aecb0f84d4e269d0d1b3b20d6e


-- 
DragonFly BSD source repository





More information about the Commits mailing list