From owner-svn-src-head@FreeBSD.ORG Mon Mar 30 14:46:03 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79CBF1065673; Mon, 30 Mar 2009 14:46:03 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from gizmo.2hip.net (gizmo.2hip.net [64.74.207.195]) by mx1.freebsd.org (Postfix) with ESMTP id 434668FC13; Mon, 30 Mar 2009 14:46:03 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from [192.168.1.156] (adsl-157-58-177.bna.bellsouth.net [70.157.58.177]) (authenticated bits=0) by gizmo.2hip.net (8.14.3/8.14.3) with ESMTP id n2UEigef066455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 30 Mar 2009 10:44:42 -0400 (EDT) (envelope-from rnoland@FreeBSD.org) From: Robert Noland To: Konstantin Belousov In-Reply-To: <200903300847.n2U8lSGo058512@svn.freebsd.org> References: <200903300847.n2U8lSGo058512@svn.freebsd.org> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-QdYJipDL6I4iFH2LLB3j" Organization: FreeBSD Date: Mon, 30 Mar 2009 09:45:29 -0500 Message-Id: <1238424329.8491.328.camel@balrog.2hip.net> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 FreeBSD GNOME Team Port X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_PBL, RDNS_DYNAMIC autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on gizmo.2hip.net Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r190543 - in head: include libexec/rtld-elf sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2009 14:46:04 -0000 --=-QdYJipDL6I4iFH2LLB3j Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Mon, 2009-03-30 at 08:47 +0000, Konstantin Belousov wrote: > Author: kib > Date: Mon Mar 30 08:47:28 2009 > New Revision: 190543 > URL: http://svn.freebsd.org/changeset/base/190543 >=20 > Log: > Implement support for RTLD_NODELETE flag for dlopen() and -z nodelete > static linker option. Do it by incrementing reference count on the load= ed > object and its dependencies. Cool, I can drop my patches to compiz now. robert. > Reviewed by: davidxu, kan >=20 > Modified: > head/include/dlfcn.h > head/libexec/rtld-elf/rtld.c > head/libexec/rtld-elf/rtld.h > head/sys/sys/elf_common.h >=20 > Modified: head/include/dlfcn.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/include/dlfcn.h Mon Mar 30 08:44:29 2009 (r190542) > +++ head/include/dlfcn.h Mon Mar 30 08:47:28 2009 (r190543) > @@ -47,6 +47,7 @@ > #define RTLD_GLOBAL 0x100 /* Make symbols globally available. */ > #define RTLD_LOCAL 0 /* Opposite of RTLD_GLOBAL, and the default. */ > #define RTLD_TRACE 0x200 /* Trace loaded objects and exit. */ > +#define RTLD_NODELETE 0x01000 /* Do not remove members. */ > =20 > /* > * Request arguments for dlinfo(). >=20 > Modified: head/libexec/rtld-elf/rtld.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/libexec/rtld-elf/rtld.c Mon Mar 30 08:44:29 2009 (r190542) > +++ head/libexec/rtld-elf/rtld.c Mon Mar 30 08:47:28 2009 (r190543) > @@ -937,6 +937,8 @@ digest_dynamic(Obj_Entry *obj, int early > /* XXX */; > if (dynp->d_un.d_val & DF_1_BIND_NOW) > obj->bind_now =3D true; > + if (dynp->d_un.d_val & DF_1_NODELETE) > + obj->z_nodelete =3D true; > break; > =20 > default: > @@ -1422,15 +1424,21 @@ is_exported(const Elf_Sym *def) > static int > load_needed_objects(Obj_Entry *first) > { > - Obj_Entry *obj; > + Obj_Entry *obj, *obj1; > =20 > for (obj =3D first; obj !=3D NULL; obj =3D obj->next) { > Needed_Entry *needed; > =20 > for (needed =3D obj->needed; needed !=3D NULL; needed =3D needed->nex= t) { > - needed->obj =3D load_object(obj->strtab + needed->name, obj); > - if (needed->obj =3D=3D NULL && !ld_tracing) > + obj1 =3D needed->obj =3D load_object(obj->strtab + needed->name, ob= j); > + if (obj1 =3D=3D NULL && !ld_tracing) > return -1; > + if (obj1 !=3D NULL && obj1->z_nodelete && !obj1->ref_nodel) { > + dbg("obj %s nodelete", obj1->path); > + init_dag(obj1); > + ref_dag(obj1); > + obj1->ref_nodel =3D true; > + } > } > } > =20 > @@ -1976,12 +1984,13 @@ dlopen(const char *name, int mode) > Obj_Entry **old_obj_tail; > Obj_Entry *obj; > Objlist initlist; > - int result, lockstate; > + int result, lockstate, nodelete; > =20 > LD_UTRACE(UTRACE_DLOPEN_START, NULL, NULL, 0, mode, name); > ld_tracing =3D (mode & RTLD_TRACE) =3D=3D 0 ? NULL : "1"; > if (ld_tracing !=3D NULL) > environ =3D (char **)*get_program_var_addr("environ"); > + nodelete =3D mode & RTLD_NODELETE; > =20 > objlist_init(&initlist); > =20 > @@ -2029,6 +2038,11 @@ dlopen(const char *name, int mode) > if (ld_tracing) > goto trace; > } > + if (obj !=3D NULL && (nodelete || obj->z_nodelete) && !obj->ref_nodel) = { > + dbg("obj %s nodelete", obj->path); > + ref_dag(obj); > + obj->z_nodelete =3D obj->ref_nodel =3D true; > + } > } > =20 > LD_UTRACE(UTRACE_DLOPEN_STOP, obj, NULL, 0, obj ? obj->dl_refcount := 0, >=20 > Modified: head/libexec/rtld-elf/rtld.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/libexec/rtld-elf/rtld.h Mon Mar 30 08:44:29 2009 (r190542) > +++ head/libexec/rtld-elf/rtld.h Mon Mar 30 08:47:28 2009 (r190543) > @@ -217,6 +217,8 @@ typedef struct Struct_Obj_Entry { > bool tls_done : 1; /* Already allocated offset for static TLS */ > bool phdr_alloc : 1; /* Phdr is allocated and needs to be freed. */ > bool z_origin : 1; /* Process rpath and soname tokens */ > + bool z_nodelete : 1; /* Do not unload the object and dependencies */ > + bool ref_nodel : 1; /* refcount increased to prevent dlclose */ > =20 > struct link_map linkmap; /* for GDB and dlinfo() */ > Objlist dldags; /* Object belongs to these dlopened DAGs (%) */ >=20 > Modified: head/sys/sys/elf_common.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/sys/elf_common.h Mon Mar 30 08:44:29 2009 (r190542) > +++ head/sys/sys/elf_common.h Mon Mar 30 08:47:28 2009 (r190543) > @@ -469,6 +469,7 @@ typedef struct { > /* Values for DT_FLAGS_1 */ > #define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */ > #define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */ > +#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ > #define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */ > =20 > /* Values for n_type. Used in core files. */ --=20 Robert Noland FreeBSD --=-QdYJipDL6I4iFH2LLB3j Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (FreeBSD) iEYEABECAAYFAknQ2wkACgkQM4TrQ4qfROOifACcDILXoAZ7HZmAMz5kDq9bHQ2A 8g8AoIYUAH03OSV7FHReZk2kApgeCKLd =JYrV -----END PGP SIGNATURE----- --=-QdYJipDL6I4iFH2LLB3j--