From 2d3fe26edea36d31e4691f4a36956d9b6ef35ab1 Mon Sep 17 00:00:00 2001 From: kib Date: Wed, 9 Feb 2011 09:20:27 +0000 Subject: [PATCH] Use sigsetjmp/siglongjmp with disabled signal mask access for lock upgrade in rtld. There is no need to care about the mask, which causes a lot of unneeded sigprocmask(2) calls during each symbol lookup. --- libexec/rtld-elf/rtld.c | 6 +++--- libexec/rtld-elf/rtld.h | 2 +- libexec/rtld-elf/rtld_lock.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 50ab393063de..948cf49471bb 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -560,7 +560,7 @@ _rtld_bind(Obj_Entry *obj, Elf_Size reloff) RtldLockState lockstate; rlock_acquire(rtld_bind_lock, &lockstate); - if (setjmp(lockstate.env) != 0) + if (sigsetjmp(lockstate.env, 0) != 0) lock_upgrade(rtld_bind_lock, &lockstate); if (obj->pltrel) rel = (const Elf_Rel *) ((caddr_t) obj->pltrel + reloff); @@ -2142,7 +2142,7 @@ dlopen(const char *name, int mode) ld_tracing = (mode & RTLD_TRACE) == 0 ? NULL : "1"; if (ld_tracing != NULL) { rlock_acquire(rtld_bind_lock, &lockstate); - if (setjmp(lockstate.env) != 0) + if (sigsetjmp(lockstate.env, 0) != 0) lock_upgrade(rtld_bind_lock, &lockstate); environ = (char **)*get_program_var_addr("environ", &lockstate); lock_release(rtld_bind_lock, &lockstate); @@ -2264,7 +2264,7 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve, req.lockstate = &lockstate; rlock_acquire(rtld_bind_lock, &lockstate); - if (setjmp(lockstate.env) != 0) + if (sigsetjmp(lockstate.env, 0) != 0) lock_upgrade(rtld_bind_lock, &lockstate); if (handle == NULL || handle == RTLD_NEXT || handle == RTLD_DEFAULT || handle == RTLD_SELF) { diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index 8941d29298d0..bb365a7ce7e6 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -276,7 +276,7 @@ typedef struct Struct_DoneList { struct Struct_RtldLockState { int lockstate; - jmp_buf env; + sigjmp_buf env; }; /* diff --git a/libexec/rtld-elf/rtld_lock.c b/libexec/rtld-elf/rtld_lock.c index e76a4da8adf8..024e1e2028db 100644 --- a/libexec/rtld-elf/rtld_lock.c +++ b/libexec/rtld-elf/rtld_lock.c @@ -259,7 +259,7 @@ lock_restart_for_upgrade(RtldLockState *lockstate) case RTLD_LOCK_WLOCKED: break; case RTLD_LOCK_RLOCKED: - longjmp(lockstate->env, 1); + siglongjmp(lockstate->env, 1); break; default: assert(0);