Date: Sun, 16 Jul 2006 21:07:00 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Roland Dittel <Roland.Dittel@web.de> Cc: hackers@freebsd.org, Simon 'corecode' Schubert <corecode@fs.ei.tum.de> Subject: Re: dlsym() on implicit loaded symbols Message-ID: <20060716180700.GP32624@deviant.kiev.zoral.com.ua> In-Reply-To: <b8fb00de744cf96704f801f919ec205b@web.de> References: <62d3f75eb4400604406fdea341d91e41@web.de> <44B92FD7.90801@fs.ei.tum.de> <44BA1B7B.8000305@web.de> <44BA31FE.7070200@fs.ei.tum.de> <b8fb00de744cf96704f801f919ec205b@web.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--JvUS8mwutKMHKosv
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Sun, Jul 16, 2006 at 03:26:33PM +0200, Roland Dittel wrote:
>=20
> Am 16.07.2006 um 14:33 schrieb Simon 'corecode' Schubert:
>=20
> >Roland Dittel wrote:
> >>>>We have a issue with dlsym() on symbols imported by a library that=20
> >>>>was loaded with dlopen(). Our code loads the libssl with dlopen()=20
> >>>>and then do a dlsym() on several symbols. This works for all=20
> >>>>symbols exported by libssl itself but fails for symbols exported by=
=20
> >>>>libcrypto.
> >[..]
> >> func =3D dlsym(handle, "CRYPTO_set_id_callback");
> >
> >you have to use RTLD_DEFAULT instead of handle, but I agree, this is=20
> >not in conformance with SUSv3:
>=20
> That's it. Thank you very much.
>=20
> Roland
>=20
> >
> > The dlsym() function shall search for the named symbol in all=20
> >objects loaded automatically as a result of loading the object=20
> >referenced by handle (see dlopen()). Load ordering is used in dlsym()=20
> >operations upon the global symbol object. The symbol resolution=20
> >algorithm used shall be dependency order as described in dlopen().
> >
> > The RTLD_DEFAULT and RTLD_NEXT flags are reserved for future use.
> >
> >Note "in all objects loaded automatically". Good catch!
> >
Try this (against RELENG_6), patch for CURRENT needs some editing.
Index: 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
RCS file: /usr/local/arch/ncvs/src/libexec/rtld-elf/rtld.c,v
retrieving revision 1.106.2.2
diff -u -r1.106.2.2 rtld.c
--- rtld.c 30 Dec 2005 22:13:56 -0000 1.106.2.2
+++ rtld.c 16 Jul 2006 18:05:39 -0000
@@ -123,7 +123,7 @@
static const Elf_Sym *symlook_default(const char *, unsigned long hash,
const Obj_Entry *refobj, const Obj_Entry **defobj_out, bool in_plt);
static const Elf_Sym *symlook_list(const char *, unsigned long,
- Objlist *, const Obj_Entry **, bool in_plt, DoneList *);
+ const Objlist *, const Obj_Entry **, bool in_plt, DoneList *);
static void trace_loaded_objects(Obj_Entry *obj);
static void unlink_object(Obj_Entry *);
static void unload_object(Obj_Entry *);
@@ -1805,25 +1805,22 @@
def =3D symlook_default(name, hash, obj, &defobj, true);
}
} else {
+ DoneList donelist;
+
if ((obj =3D dlcheck(handle)) =3D=3D NULL) {
rlock_release(rtld_bind_lock, lockstate);
return NULL;
}
=20
+ donelist_init(&donelist);
if (obj->mainprog) {
- DoneList donelist;
=20
/* Search main program and all libraries loaded by it. */
- donelist_init(&donelist);
def =3D symlook_list(name, hash, &list_main, &defobj, true,
&donelist);
} else {
- /*
- * XXX - This isn't correct. The search should include the whole
- * DAG rooted at the given object.
- */
- def =3D symlook_obj(name, hash, obj, true);
- defobj =3D obj;
+ def =3D symlook_list(name, hash, &(obj->dagmembers), &defobj, true,
+ &donelist);
}
}
=20
@@ -2274,7 +2271,7 @@
}
=20
static const Elf_Sym *
-symlook_list(const char *name, unsigned long hash, Objlist *objlist,
+symlook_list(const char *name, unsigned long hash, const Objlist *objlist,
const Obj_Entry **defobj_out, bool in_plt, DoneList *dlp)
{
const Elf_Sym *symp;
--JvUS8mwutKMHKosv
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (FreeBSD)
iD8DBQFEuoBDC3+MBN1Mb4gRApgAAKC+IOPo/dHm5SnzfTHYikN2vfXnIQCgn6/f
imNm8J4tjJ0MyvLCzeC8bLw=
=VGKN
-----END PGP SIGNATURE-----
--JvUS8mwutKMHKosv--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060716180700.GP32624>
