rtld-elf - Notify thread state to optimize relocations
commit50caca1a70a5f1f9dfba401f114bed0e721bbb0f
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 12 May 2019 04:01:55 +0000 (11 21:01 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 12 May 2019 04:07:40 +0000 (11 21:07 -0700)
treedbf2c8c6f2dd27015c27b89411d972b90a0d032c
parent5b329e620879c577bf125590808f5146f61a19bb
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
lib/libc/gen/Symbol.map
lib/libc/gen/dlfcn.c
lib/libthread_xu/thread/thr_kern.c
lib/libthread_xu/thread/thr_private.h
libexec/rtld-elf/Symbol.map
libexec/rtld-elf/rtld.c
libexec/rtld-elf/rtld_lock.c