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
rtld - Add fork hooks for libthread_xu to install * Add fork hooks for libthread_xu to install. rtld must acquire its locks exclusively during a fork, and then release them after the fork is complete, to prevent the fork() from catching the locks in a bad state. See libthread_xu.
libc/libpthread: Inject threadsafe locking callbacks for rtld. * Make rtld thread-safe. Add lib/libthread_xu/thread/thr_rtld.c to the build and use it to inject pthread based locking callbacks for rtld. * In rtld_lock.c, do the thread_mask_clear(lock->mask); after releasing the actual lock, to avoid deadlocks when rtld is called recursively from the pthread locking callbacks. XXX An alternative solution for this issue would be, to flag the libpthread dynamic library as bind_now to avoid the recursive rtld calls.
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
rtld: Compress FreeBSD CVSIDs The FreeBSD repository is still handled by CVS, but its converted to Subversion and from that, git. Neither the svn nor git version feature expanded $FreeBSD$ tags. The only way to get this is to pull directly from CVS which isn't convenient. In the case of a few files, the only difference between the DragonFly version and the FreeBSD version is the CVS tag. As the main development of rtld is happening on FreeBSD and since I've started collaborating with FreeBSD developers on new dynamic linker features, we want to actively keep our linkers synchronized. Compressing the FreeBSD CVSID tags makes that easier for me, the only person currently maintaining the dynamic linker. The usually-wrong expanded CVS tag wasn't providing any useful information to me either.
rtld-elf: Sync with FreeBSD The DragonFly run-time linker receives its first upgrade since TLS was added. Highlights include improvements to dl functionality: dlvsym dl_iterate_phdr _rtld_addr_phdr improved dlfunct Improved security for dangerous LD environment variables were added. Several bugs were fixed. libmap.conf functionality was added. utrace/ktrace support added. Improved atexit and cxa_atexit finalization. ELF symbol versioning using gnu semantics. ldd and kdump improvments significant man page updates dynamic token expansion functionlity added. new locking mechanism Support for env var LD_ELF_HINTS_PATH Support for RTLD_NODELETE and RTLD_NOLOAD flags for dlopen dlfunc moved from libc to rtld The next GCC upgrade will take advantage of this rtld upgrade in order to improve exception handling. DragonFly has never used the shared libgcc_s which has impeded (or broke?) C++ exception handling. This commit syncs rtld-elf to the FreeBSD cerca 16 DEC 2010. However, bug fixes between then and 25 March 2011 have been included, but major functionality changes from the ELF Filter support on 25 DEC 2010 onwards has been excluded.