Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 04 Oct 2013 17:39:37 -0400
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>,  Sevan / Venture37 <venture37@gmail.com>
Cc:        jlh@freebsd.org, java@FreeBSD.org, Jimmy Olgeni <olgeni@freebsd.org>
Subject:   Re: JNA broken with r251668 as libc.so cant be loaded
Message-ID:  <524F3599.4060708@FreeBSD.org>
In-Reply-To: <524F2FD2.3020801@FreeBSD.org>
References:  <524DFB7D.2000207@gmail.com> <20131004050824.GK41229@kib.kiev.ua> <524E934D.70303@gmail.com> <20131004152000.GS41229@kib.kiev.ua> <524F2FD2.3020801@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------050409050902070804060403
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2013-10-04 17:14:58 -0400, Jung-uk Kim wrote:
> On 2013-10-04 11:20:00 -0400, Konstantin Belousov wrote:
>> On Fri, Oct 04, 2013 at 02:07:09PM +0400, Sevan / Venture37
>> wrote:
>>> On 04/10/2013 09:08, Konstantin Belousov wrote:
>>>> Does the source contain some workaround for Linux, already ? 
>>>> Linux uses script for libc.so for very long time, and should 
>>>> have the same issue unless code explicitely dlopen()s
>>>> libc.so.6 or such.
>>> 
>>> 
>>> No 
>>> https://svn.java.net/svn/jna~svn/trunk/jnalib/test/com/sun/jna/LibraryLoadTest.java
>
>>> 
>>> 
>> I do not know what should I see in the pointer you provided, and 
>> how it implies the answer 'No' to my question.
> 
>> I just verified dlopen("libc.so") on some fresh Linux box, and
>> the function returned expected error '/lib/libc.so: invalid ELF 
>> header'.
> 
> I haven't verified it but it seems to have special case for Linux. 
> Please see:
> 
> https://github.com/twall/jna/blob/master/src/com/sun/jna/NativeLibrary.java#L206
>
> 
https://github.com/twall/jna/blob/master/src/com/sun/jna/NativeLibrary.java#L741
> https://github.com/twall/jna/blob/master/src/com/sun/jna/NativeLibrary.java#L768

Verified.
> 
This simple patch fixed the problem for me.

http://people.freebsd.org/~jkim/jna.diff

Cheers,

Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (FreeBSD)

iQEcBAEBAgAGBQJSTzWZAAoJEHyflib82/FGl+YIAIWWYgj5+30j648gZJgVF0G/
M2RglpJkjw4w6mdges/AskVvzZSPSQ8/dJVg0Al84Uv2ci7G+cyRivOOowJ7iIZN
qrUF44OFRTMhmJMDvqA9zTqfn1VbYf+sdnxpJL8iy43wqhQqFVjXdN0UIHFTKRak
plS3VKSzDorNaegyJZiEfTPeRTW/tsj9iPX1+NgJ7w1/hag7A3h3rcKZYPtSvocQ
SEsNsFwVdK9lkRFPNdgJT/gocTZZJkuEN3gZ4CAncs6Z4ONfU+xgXCXXsI1jqmFH
lBssPWKz8QrJC9VHWpDMMVFLNSNsQVFY15ZDPn126jHwP2mVTZNlrPcV7VNTN1E=
=OszO
-----END PGP SIGNATURE-----

--------------050409050902070804060403
Content-Type: text/x-patch;
 name="jna.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="jna.diff"

Index: devel/jna/Makefile
===================================================================
--- devel/jna/Makefile	(revision 329377)
+++ devel/jna/Makefile	(working copy)
@@ -2,6 +2,7 @@
 
 PORTNAME=	jna
 PORTVERSION=	4.0
+PORTREVISION=	1
 CATEGORIES=	devel java
 MASTER_SITES=	GH
 
Index: devel/jna/files/patch-src__com__sun__jna__NativeLibrary.java
===================================================================
--- devel/jna/files/patch-src__com__sun__jna__NativeLibrary.java	(revision 0)
+++ devel/jna/files/patch-src__com__sun__jna__NativeLibrary.java	(working copy)
@@ -0,0 +1,29 @@
+--- src/com/sun/jna/NativeLibrary.java.orig	2013-07-04 14:42:30.000000000 -0400
++++ src/com/sun/jna/NativeLibrary.java	2013-10-04 17:28:07.000000000 -0400
+@@ -203,7 +203,7 @@
+                 }
+                 catch(UnsatisfiedLinkError e2) { e = e2; }
+             }
+-            else if (Platform.isLinux()) {
++            else if (Platform.isLinux() || Platform.isFreeBSD()) {
+                 //
+                 // Failed to load the library normally - try to match libfoo.so.*
+                 //
+@@ -382,7 +382,7 @@
+ 
+         // Use current process to load libraries we know are already
+         // loaded by the VM to ensure we get the correct version
+-        if ((Platform.isLinux() || Platform.isAIX())
++        if ((Platform.isLinux() || Platform.isFreeBSD() || Platform.isAIX())
+             && Platform.C_LIBRARY_NAME.equals(libraryName)) {
+             libraryName = null;
+         }
+@@ -702,7 +702,7 @@
+             }
+             return name;
+         }
+-        else if (Platform.isLinux()) {
++        else if (Platform.isLinux() || Platform.isFreeBSD()) {
+             if (isVersionedName(libName) || libName.endsWith(".so")) {
+                 // A specific version was requested - use as is for search
+                 return libName;

Property changes on: devel/jna/files/patch-src__com__sun__jna__NativeLibrary.java
___________________________________________________________________
Added: fbsd:nokeywords
## -0,0 +1 ##
+yes
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property

--------------050409050902070804060403--



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