git: rtld-elf - Notify thread state to optimize relocations

Matthew Dillon dillon at
Sat May 11 21:07:43 PDT 2019

commit 50caca1a70a5f1f9dfba401f114bed0e721bbb0f
Author: Matthew Dillon <dillon at>
Date:   Sat May 11 21:01:55 2019 -0700

    rtld-elf - Notify thread state to optimize relocations
    * Add shims to allow libthread_xu to notify rtld when threading
      is being used.
    * Requires weak symbols in libc which are overriden by rtld-elf.
    * Implement the feature in rtld-elf and use it to avoid making calls
      to lwp_gettid().  When threaded, use tls_get_tcb() (which does not
      require a system call) instead of lwp_gettid().  When not threaded,
      just use a constant.
      NOTE: We cannot use tls_get_tcb() unconditionally because the tcb
    	is not setup during early relocations.  So do this whack-a-mole
    	to make it work.
    * This leaves just the sigprocmask wrappers around rtld-elf (which
      are needed to prevent stacked relocations from signal handlers).
    Poked-by: mjg

Summary of changes:
 lib/libc/gen/               |  1 +
 lib/libc/gen/dlfcn.c                  |  8 ++++
 lib/libthread_xu/thread/thr_kern.c    |  1 +
 lib/libthread_xu/thread/thr_private.h |  1 +
 libexec/rtld-elf/           |  1 +
 libexec/rtld-elf/rtld.c               |  1 +
 libexec/rtld-elf/rtld_lock.c          | 71 ++++++++++++++++++++++++++---------
 7 files changed, 66 insertions(+), 18 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list