From b683fcf69217f7195e73b2f05d608c952101f47a Mon Sep 17 00:00:00 2001 From: kib Date: Thu, 27 Nov 2008 11:27:59 +0000 Subject: Add two rtld exported symbols, _rtld_atfork_pre and _rtld_atfork_post. Threading library calls _pre before the fork, allowing the rtld to lock itself to ensure that other threads of the process are out of dynamic linker. _post releases the locks. This allows the rtld to have consistent state in the child. Although child may legitimately call only async-safe functions, the call may need plt relocation resolution, and this requires working rtld. Reported and debugging help by: rink Reviewed by: kan, davidxu MFC after: 1 month (anyway, not before 7.1 is out) --- lib/libc/gen/Symbol.map | 2 ++ lib/libc/gen/dlfcn.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) (limited to 'lib/libc') diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 6e8bfce..2e64313 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -432,6 +432,8 @@ FBSDprivate_1.0 { _spinlock; _spinlock_debug; _spinunlock; + _rtld_atfork_pre; + _rtld_atfork_post; _rtld_error; /* for private use */ _rtld_thread_init; /* for private use */ _err; diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index 39ba141..eac3f1a 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -137,3 +137,15 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), _rtld_error(sorry); return 0; } + +#pragma weak _rtld_atfork_pre +void +_rtld_atfork_pre(int *locks) +{ +} + +#pragma weak _rtld_atfork_post +void +_rtld_atfork_post(int *locks) +{ +} -- cgit v1.1