From owner-freebsd-current@FreeBSD.ORG Wed Oct 8 23:55:56 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9DAE2106568A for ; Wed, 8 Oct 2008 23:55:56 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.237]) by mx1.freebsd.org (Postfix) with ESMTP id 503298FC1A for ; Wed, 8 Oct 2008 23:55:56 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: by wr-out-0506.google.com with SMTP id c8so801286wra.27 for ; Wed, 08 Oct 2008 16:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=OUsRtGbFiQi7tEgkQHVqMXL6GcpdMAtRz3qKtDU8kRw=; b=erGUeGXQ94rMTKHW5cWKeuj60g0ZL1zI4F4dF1cAgXQZ1efQxBHd6HPIXgpaEifJvj kD8QlCz5fi9qZM4hAj8MvmfU1BYWLzqke1YMmv1hdmFj8yS7agTLEZPYx6Im8sw+c5Y5 WAp3xh4nSJUSFWr/T2yAxOgcqEUxgUI0TMRyA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=OqWcdx6l5+M3IodFtcipA/yoOIXCZJi+dVokB7ygLSD7hCTVfO9lwkpUZGJ9erR83t GjGDJOUWerHamxTawqjdQETprMcSXHrVyk2L0dZ+EFLX1GwzW8zPSv0yMLxWXG1emJm0 1GgKH88HrFjoOnBslEBb0fHsMNUjgv9G/c6Bo= Received: by 10.150.92.13 with SMTP id p13mr6562845ybb.145.1223508550665; Wed, 08 Oct 2008 16:29:10 -0700 (PDT) Received: from kan.dnsalias.net (c-24-62-106-68.hsd1.ma.comcast.net [24.62.106.68]) by mx.google.com with ESMTPS id p27sm927424ele.0.2008.10.08.16.29.09 (version=SSLv3 cipher=RC4-MD5); Wed, 08 Oct 2008 16:29:09 -0700 (PDT) Date: Wed, 8 Oct 2008 19:29:05 -0400 From: Alexander Kabaev To: Maxim Sobolev Message-ID: <20081008192905.0b75b0a6@kan.dnsalias.net> In-Reply-To: <48ED3545.6030609@FreeBSD.org> References: <48ED27EA.9020407@FreeBSD.org> <48ED3545.6030609@FreeBSD.org> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.11; i386-portbld-freebsd8.0) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/iKWPDK2+MyrwaEDHj5BqloR"; protocol="application/pgp-signature"; micalg=PGP-SHA1 Cc: Alexander Kabaev , "current@freebsd.org" Subject: Re: dlsym(RTLD_NEXT) and weak symbols X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Oct 2008 23:55:56 -0000 --Sig_/iKWPDK2+MyrwaEDHj5BqloR Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 08 Oct 2008 15:33:41 -0700 Maxim Sobolev wrote: >=20 > The following patch fixes the issue for me: > I do not think your patch is completely correct. How about this one instead:=20 =3D=3D=3D 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 --- rtld.c (revision 183657) +++ rtld.c (local) @@ -1925,7 +1925,7 @@ { DoneList donelist; const Obj_Entry *obj, *defobj; - const Elf_Sym *def; + const Elf_Sym *def, *symp; unsigned long hash; int lockstate; =20 @@ -1951,11 +1951,28 @@ if (handle =3D=3D RTLD_NEXT) obj =3D obj->next; for (; obj !=3D NULL; obj =3D obj->next) { - if ((def =3D symlook_obj(name, hash, obj, ve, flags)) !=3D NULL) { - defobj =3D obj; - break; + if ((symp =3D symlook_obj(name, hash, obj, ve, flags)) !=3D NULL) { + if (def =3D=3D NULL || ELF_ST_BIND(symp->st_info) !=3D STB_WEAK) { + def =3D symp; + defobj =3D obj; + if (ELF_ST_BIND(def->st_info) !=3D STB_WEAK) + break; + } } } + /* + * Search the dynamic linker itself, and possibly resolve the + * symbol from there. This is how the application links to + * dynamic linker services such as dlopen. Only the values listed + * in the "exports" array can be resolved from the dynamic linker. + */ + if (def =3D=3D NULL || ELF_ST_BIND(def->st_info) =3D=3D STB_WEAK) { + symp =3D symlook_obj(name, hash, &obj_rtld, ve, flags); + if (symp !=3D NULL && is_exported(symp)) { + def =3D symp; + defobj =3D &obj_rtld; + } + } } else { assert(handle =3D=3D RTLD_DEFAULT); def =3D symlook_default(name, hash, obj, &defobj, ve, flags); --Sig_/iKWPDK2+MyrwaEDHj5BqloR Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iD8DBQFI7UJBQ6z1jMm+XZYRAimTAJ4sud5blRPU3p56/6DOBLj042J4NgCfRefv qN8RLZfeIQ7PznnKigTBvm4= =h2Bm -----END PGP SIGNATURE----- --Sig_/iKWPDK2+MyrwaEDHj5BqloR--