From owner-freebsd-openoffice@FreeBSD.ORG Sun Jun 14 10:16:09 2009 Return-Path: Delivered-To: openoffice@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 916A9106566C; Sun, 14 Jun 2009 10:16:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id 2E7CA8FC13; Sun, 14 Jun 2009 10:16:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1MFmDh-00054c-KT; Sun, 14 Jun 2009 12:41:45 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n5E9fftU071963 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 14 Jun 2009 12:41:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n5E9ffph055526; Sun, 14 Jun 2009 12:41:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n5E9fflI055525; Sun, 14 Jun 2009 12:41:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 14 Jun 2009 12:41:41 +0300 From: Kostik Belousov To: Maho NAKATA Message-ID: <20090614094141.GF23592@deviant.kiev.zoral.com.ua> References: <20090613.175239.193757216.chat95@mac.com> <20090613.211918.71168302.chat95@mac.com> <1244902235.49065.33.camel@localhost> <20090614.081457.193757375.chat95@mac.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qftxBdZWiueWNAVY" Content-Disposition: inline In-Reply-To: <20090614.081457.193757375.chat95@mac.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.1 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, URIBL_RHS_DOB autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1MFmDh-00054c-KT 3f0b0d31156d5c7a2cb99109ad1a8c5a X-Terabit: YES Cc: kan@freebsd.org, openoffice@freebsd.org Subject: Re: ld.so slight difference Linux and FreeBSD ports/127946 X-BeenThere: freebsd-openoffice@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting OpenOffice to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jun 2009 10:16:09 -0000 --qftxBdZWiueWNAVY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jun 14, 2009 at 08:14:57AM +0900, Maho NAKATA wrote: > Hello Konstantin, and * >=20 > We have a longstanding OpenOffice.org porting issue for FreeBSD. > Strange crashes. > So I'd like to ask you about following issue.=20 > http://www.openoffice.org/issues/show_bug.cgi?id=3D22253 > . > There are some small difference between ld.so implementation > between FreeBSD and Linux. Here is the test program that identify > the difference clearly. (it also applies to NetBSD) >=20 > ------------------------------------------------ > "dlsym() search _on_the_main_program_" i.e. the handle is not the > dlopen()ed shared library itself, but the main program (which you get > back with dlopen(NULL, RTLD_LAZY) ) > I've modified your test program a bit: >=20 > #include > #include > #include >=20 > int main(int argc, char **argv) { > void *handle, *handlemain; > double (*cosine)(double); > char *error; >=20 > handle =3D dlopen ("libm.so", RTLD_LAZY|RTLD_GLOBAL); > if (!handle) { > fprintf (stderr, "%s\n", dlerror()); > exit(1); > } >=20 > handlemain =3D dlopen(NULL, RTLD_LAZY); > cosine =3D dlsym(handlemain, "cos"); > if ((error =3D dlerror()) !=3D NULL) { > fprintf (stderr, "%s\n", error); > exit(1); > } >=20 > printf ("%f\n", (*cosine)(2.0)); > dlclose(handle); > return 0; > } >=20 > On Linux: > bash-2.05b$ ./a.out=20 > -0.416147 >=20 > while on NetBSD: > -bash-2.05b$ ./a.out=20 > Undefined symbol "cos" > ------------------------------------------------ >=20 > It seems that this is the root cause of some issues. > http://www.openoffice.org/issues/show_bug.cgi?id=3D22253 > http://www.openoffice.org/issues/show_bug.cgi?id=3D98781 > maybe also > http://www.freebsd.org/cgi/query-pr.cgi?pr=3D128176 >=20 > It seems ld.so employs same mechanism between Linux and MacOSX. >=20 > Could you please help me a bit? According to the Solaris dlopen(3) and dlsym(3) documentation, objects opened with RTLD_GLOBAL shall participate in any dlsym() search. Please, try the following patch. diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 40ed6ed..2badcfc 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2141,6 +2141,11 @@ do_dlsym(void *handle, const char *name, void *retad= dr, const Ver_Entry *ve, &donelist); } } + if (def =3D=3D NULL) { + donelist_init(&donelist); + def =3D symlook_list(name, hash, &list_global, &defobj, ve, flags, + &donelist); + } =20 if (def !=3D NULL) { rlock_release(rtld_bind_lock, lockstate); --qftxBdZWiueWNAVY Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAko0xdQACgkQC3+MBN1Mb4gbzQCg2BFSMDvYKzodMzb9Kg5FQtlm uzUAoJCmKRKNWmGJ6CpV1b2lnig4XIen =ifDd -----END PGP SIGNATURE----- --qftxBdZWiueWNAVY--