Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Feb 2011 09:20:27 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r218476 - head/libexec/rtld-elf
Message-ID:  <201102090920.p199KRn5077698@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Feb  9 09:20:27 2011
New Revision: 218476
URL: http://svn.freebsd.org/changeset/base/218476

Log:
  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.

Modified:
  head/libexec/rtld-elf/rtld.c
  head/libexec/rtld-elf/rtld.h
  head/libexec/rtld-elf/rtld_lock.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Wed Feb  9 08:01:45 2011	(r218475)
+++ head/libexec/rtld-elf/rtld.c	Wed Feb  9 09:20:27 2011	(r218476)
@@ -560,7 +560,7 @@ _rtld_bind(Obj_Entry *obj, Elf_Size relo
     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,
     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) {

Modified: head/libexec/rtld-elf/rtld.h
==============================================================================
--- head/libexec/rtld-elf/rtld.h	Wed Feb  9 08:01:45 2011	(r218475)
+++ head/libexec/rtld-elf/rtld.h	Wed Feb  9 09:20:27 2011	(r218476)
@@ -276,7 +276,7 @@ typedef struct Struct_DoneList {
 
 struct Struct_RtldLockState {
 	int lockstate;
-	jmp_buf env;
+	sigjmp_buf env;
 };
 
 /*

Modified: head/libexec/rtld-elf/rtld_lock.c
==============================================================================
--- head/libexec/rtld-elf/rtld_lock.c	Wed Feb  9 08:01:45 2011	(r218475)
+++ head/libexec/rtld-elf/rtld_lock.c	Wed Feb  9 09:20:27 2011	(r218476)
@@ -259,7 +259,7 @@ lock_restart_for_upgrade(RtldLockState *
 	case RTLD_LOCK_WLOCKED:
 		break;
 	case RTLD_LOCK_RLOCKED:
-		longjmp(lockstate->env, 1);
+		siglongjmp(lockstate->env, 1);
 		break;
 	default:
 		assert(0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102090920.p199KRn5077698>