Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Nov 2016 11:59:20 +0100
From:      Matthieu Volat <mazhe@alkumuna.eu>
To:        freebsd-java@freebsd.org
Subject:   Trying to locate function using dlfunc with RLTD_NEXT from JNI
Message-ID:  <20161130115920.444d7a76@freedom.alkumuna.eu>

next in thread | raw e-mail | index | archive | help
--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 <mazhe@alkumuna.eu>


--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161130115920.444d7a76>