From owner-freebsd-java@freebsd.org Wed Nov 30 10:59:31 2016 Return-Path: Delivered-To: freebsd-java@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE21CC5D7AB for ; Wed, 30 Nov 2016 10:59:31 +0000 (UTC) (envelope-from mazhe@alkumuna.eu) Received: from smtp1-g21.free.fr (smtp1-g21.free.fr [IPv6:2a01:e0c:1:1599::10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 77B84137C for ; Wed, 30 Nov 2016 10:59:31 +0000 (UTC) (envelope-from mazhe@alkumuna.eu) Received: from yggdrasil.alkumuna.eu (unknown [IPv6:2a01:e35:8a74:6e70:232:36ff:fe5c:3a87]) by smtp1-g21.free.fr (Postfix) with ESMTPS id 55946B004FE for ; Wed, 30 Nov 2016 11:59:27 +0100 (CET) Received: from freedom.alkumuna.eu ([IPv6:2a01:e35:8a74:6e70:62a4:4cff:fe54:b212]) (authenticated bits=0) by yggdrasil.alkumuna.eu (8.15.2/8.15.2) with ESMTPSA id uAUAxNB2087646 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2016 11:59:26 +0100 (CET) (envelope-from mazhe@alkumuna.eu) Date: Wed, 30 Nov 2016 11:59:20 +0100 From: Matthieu Volat To: freebsd-java@freebsd.org Subject: Trying to locate function using dlfunc with RLTD_NEXT from JNI Message-ID: <20161130115920.444d7a76@freedom.alkumuna.eu> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.29; amd64-portbld-freebsd11.0) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/4vx_.ADWKIJfbGuP5psnx0k"; protocol="application/pgp-signature" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alkumuna.eu; s=default; t=1480503566; bh=+Ift1/qsTzHAwio42FCISimFf43Txp7a6AxNMdzOC2M=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=dD6WxJjrFDJro6YixJNSnAzjX+Ua4B3mREy72DkW4m9AHUEr4la5fcpEFoQDsoClZ31MZSaIYczwzB3XMpMhzHJQsbI54jzw6HDropiZx9c9q3Vyq/+jDs7oa4Kdc7lcoe2WGoeFPzd7V1HF7z29y2Gbt30tyzhT1ioHm//ZAt4= X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Nov 2016 10:59:31 -0000 --Sig_/4vx_.ADWKIJfbGuP5psnx0k Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi, a (maybe not) tricky question for people who know well the internals of= the jdk on freebsd... Trying to port a linux project that does quite a bit of introspection, begi= ning by using malloc & co wrapper, with java binding, I found that strangel= y, you can use dlfunc(RTLD_NEXT, "malloc") in a non-java environment... But= as soon as this code is loaded in the context of the jvm, the symbol won't= be resolved. This is maybe a bit suprising as this technique worked on Linux and I did n= ot expect much difference here... Small demonstration code: % git clone https://gist.github.com/f6993d7a48ecbab6c0c979b9a7a40912.git = jni_dlfunc % cd jni_dlfunc % make [...] % ./testfoo=20 malloc function located at 0x800ade210 % java -Djava.library.path=3D. testfoo could not locate function malloc: Undefined symbol "malloc" Would anybody have an idea of why the jvm would cause the C symbols not to = be found via RTLD_NEXT and if there would be a way to workaround it (that i= s not to load explicitely "/lib/libc.so.7")? Thanks in advance --=20 Matthieu Volat --Sig_/4vx_.ADWKIJfbGuP5psnx0k Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQTxuiqPSkQnzRDOjsP4Q0N5gpmLfgUCWD6xCAAKCRD4Q0N5gpmL flWbAJ9woUj/gdMPX6mQwUwN85+YKTi6/QCglXpZjhGVDx759S7tbD3YINOZmLU= =ek2v -----END PGP SIGNATURE----- --Sig_/4vx_.ADWKIJfbGuP5psnx0k--