Re: Converting libfoo.so for linux to freebsd
On Fri, 12 Aug 2005 11:14:51 -0600 (MDT) "M. Warner Losh" <[EMAIL PROTECTED]> wrote: > In message: <[EMAIL PROTECTED]> > Jeremie Le Hen <[EMAIL PROTECTED]> writes: > : Hi Warner, Norikatsu-san, > : > : Linuxpluginwrapper(LPW) is a most famous killer application > : > : of libmap.conf(5)! (I think:-) > : > Definitely. While threading games are interesting, the linux plugin > : > wrapper definitely is much more useful. > : Why don't import this in base system and wrap it in a user friendly > : tool ? Some kind of advanced Linux compatibility. > The wrapper is specific for each library or plug-in that it wraps. It > might be hard to generalize enough to warrant inclusion in the base... I don't know in the base... But LPW Episode II will provide following feature: 1. Integratied Plugin Wrapper Library The early LPW was implemented few functions, and unstable which I thinked. To implement core functions needed by Netscape Plugins, so I splited pluginwrapper. But recently, I noticed that some functions are required by some plugins. As result, I made similar wrapper libraries. So I'll try to integrate wrapper library. 2. Add AMD64 Target Architecture I didn't make wrapper library for i386. So I'll try to split MI/MD:-). But I cannot implement amd64->i386 wrapper:-(. 3. Improved Source Tree I'll try to change source tree like FreeBSD's src/lib/libc. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
On Tue, 9 Aug 2005, M. Warner Losh wrote: In message: <[EMAIL PROTECTED]> Bernd Walter <[EMAIL PROTECTED]> writes: : On Tue, Aug 09, 2005 at 01:37:34PM -0600, M. Warner Losh wrote: : > I have recently purcahsed a device that comes with a .so for linux, : > but no sources. Is there any way one can take an arbitrary linux .so : > which appears to have no dependencies to a FreeBSD .so? The binary : > code is about 20k or so. : : Isn't this just brandelf'ing to FreeBSD-i386? : Asuming that the lib really has no dependencies to linux specific : device/kernel features or linux specific libs. I tried brandelfing, but that didn't work. There's some weird symbols in there: DF *UND* 0023 GLIBC_2.0 fprintf DF *UND* 00f8 GLIBC_2.0 fflush DF *UND* 01b4 GLIBC_2.0 malloc DF *UND* 0058 GLIBC_2.0 memmove DO *UND* 0004 GLIBC_2.0 stderr DF *UND* 020d GLIBC_2.0 abort DF *UND* 0027 GLIBC_2.0 memcpy w DF *UND* 00ac GLIBC_2.1.3 __cxa_finalize DF *UND* 0043 GLIBC_2.0 memset So it looks like I'm close... objcopy -R kept the GLIBC_* references in place, alas, so that didn't work, as suggested elsewhere in this thread. The above list is small, but has hree bad entries: fprintf, fflush and stderr. So that may present a problem for me if these functions are ever called. Warner Well, those functions do exist... except for stderr, although that is a varible (libc) The problem is that when you brandelf a .so file, it dosen't do anything, whatever uses it must be brandelf'd and compiled for linux... (well, in my experience with it it does nothing that i have noticed) If you can compile whatever needs to use it as linux then brandelf it, it should work ~Neo-Vortex ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
In message: <[EMAIL PROTECTED]> Jeremie Le Hen <[EMAIL PROTECTED]> writes: : Hi Warner, Norikatsu-san, : : > : Linuxpluginwrapper(LPW) is a most famous killer application : > : of libmap.conf(5)! (I think:-) : > : > Definitely. While threading games are interesting, the linux plugin : > wrapper definitely is much more useful. : : Why don't import this in base system and wrap it in a user friendly : tool ? Some kind of advanced Linux compatibility. The wrapper is specific for each library or plug-in that it wraps. It might be hard to generalize enough to warrant inclusion in the base... Warner ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
Hi Warner, Norikatsu-san, > : Linuxpluginwrapper(LPW) is a most famous killer application > : of libmap.conf(5)! (I think:-) > > Definitely. While threading games are interesting, the linux plugin > wrapper definitely is much more useful. Why don't import this in base system and wrap it in a user friendly tool ? Some kind of advanced Linux compatibility. Regards, -- Jeremie Le Hen < jeremie at le-hen dot org >< ttz at chchile dot org > ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
In message: <[EMAIL PROTECTED]> Norikatsu Shigemura <[EMAIL PROTECTED]> writes: : Linuxpluginwrapper(LPW) is a most famous killer application : of libmap.conf(5)! (I think:-) Definitely. While threading games are interesting, the linux plugin wrapper definitely is much more useful. : On Thu, 11 Aug 2005 10:46:04 -0600 (MDT) : "M. Warner Losh" <[EMAIL PROTECTED]> wrote: : > Here's a breif outline of what I've learned: : > (1) To remove the symbol versioning goo from a shared library, : > objcopy -R .gnu.version linux.so freebsd.so : > (there's also a .gnu.version_r on some libraries, that can : > also be removed this way). Doing this allows one to directly : > link the .so into your program, modulo ABI issues. : : Humm, When I made LPW, I didn't have a trouble about symbol : versioning. I think no need objcopy. If you are building programs from source and linking directly to these libraries, then the objcopy is needed. If you are just coaxing binaries to run that have already been linked, then no objcopy is needed. Also, if you load the library via dlopen, no objcopy is needed. : > The linuxplugwrapper port can be used to generate shims for the ABI : > issues, in general, and works well. I'll likely not use it for the : > brother scanner port I'm working on since all I need is stderr defined : > in a linuxly correct, and I can do that in the source part of the : > driver. I'd love to get the network side of things working, but I : > think that might be more effort than I care to go to at the moment. : > I'd also like to get faxing and printing working, but again, time... : > I bought it for the 35 sheet document feeder + scanner at $100.00 : > after rebate :-) : : LPW has a FORCE ABOUTER[TM:-)]. : $ cd /usr/ports/www/linuxpluginwrapper : $ make extract : $ cd work/linuxpluginwrapper-20050613 : $ make dummy.c TARGET_PLUGIN=LINUX_SHARED_LIBRARY_YOU_WANT.so : $ mv dummy.c dummy_APPLICATION_NAME.c : please add dummy_APPLICATION_NAME.o and related macros to : Makefile on top directory. : : So you can develop pluginwrapper like acrobat/flash7/realplayer : support:-). I noticed that when I was looking at the wrapepr. Definitely very cool tools to help in development. I was lucky that the Linux library I needed to run touched so few symbols. Warner ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
Linuxpluginwrapper(LPW) is a most famous killer application of libmap.conf(5)! (I think:-) On Thu, 11 Aug 2005 10:46:04 -0600 (MDT) "M. Warner Losh" <[EMAIL PROTECTED]> wrote: > Here's a breif outline of what I've learned: > (1) To remove the symbol versioning goo from a shared library, > objcopy -R .gnu.version linux.so freebsd.so > (there's also a .gnu.version_r on some libraries, that can > also be removed this way). Doing this allows one to directly > link the .so into your program, modulo ABI issues. Humm, When I made LPW, I didn't have a trouble about symbol versioning. I think no need objcopy. > (2) dlopen (and likely ld-elf.so in general) doesn't check the > version information at all. If all you are doing is linking > dynamically at run time, you don't have to perform step #1. > The compile time linker, however, whines about missing symbol > versions. > (3) Use libmap.conf to map libc.so.6 for the shared library > that you are loading to overcome ABI issues. See the man page > for an example. Humm.. I have no comment. > The linuxplugwrapper port can be used to generate shims for the ABI > issues, in general, and works well. I'll likely not use it for the > brother scanner port I'm working on since all I need is stderr defined > in a linuxly correct, and I can do that in the source part of the > driver. I'd love to get the network side of things working, but I > think that might be more effort than I care to go to at the moment. > I'd also like to get faxing and printing working, but again, time... > I bought it for the 35 sheet document feeder + scanner at $100.00 > after rebate :-) LPW has a FORCE ABOUTER[TM:-)]. $ cd /usr/ports/www/linuxpluginwrapper $ make extract $ cd work/linuxpluginwrapper-20050613 $ make dummy.c TARGET_PLUGIN=LINUX_SHARED_LIBRARY_YOU_WANT.so $ mv dummy.c dummy_APPLICATION_NAME.c please add dummy_APPLICATION_NAME.o and related macros to Makefile on top directory. So you can develop pluginwrapper like acrobat/flash7/realplayer support:-). ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
In message: <[EMAIL PROTECTED]> Hajimu UMEMOTO <[EMAIL PROTECTED]> writes: : Hi, : : > On Tue, 9 Aug 2005 16:31:30 -0500 : > Dan Nelson <[EMAIL PROTECTED]> said: : : dnelson> In the last episode (Aug 09), M. Warner Losh said: : > I have recently purcahsed a device that comes with a .so for linux, : > but no sources. Is there any way one can take an arbitrary linux .so : > which appears to have no dependencies to a FreeBSD .so? The binary : > code is about 20k or so. : : dnelson> As long as any structs that are passed back and forth have the same : dnelson> members and alignment, it should work. This includes struct FILE, : dnelson> which means if the app tries to use stdio it'll likely crash. : : dnelson> I just compiled a little "hello world" object file on SUSE and linked : dnelson> it on FreeBSD and it ran (it just calls printf, which is safe since it : dnelson> doesn't pass a FILE *). : : As far as the Linux shlib uses the functions which ABI are compatible : with FreeBSD's one, it should work. However, if there are some ABI : incompatibility, you may want to consider the approach of : linuxpluginwrapper. : The PIPS ports (print/pips*) link Linux shlib to FreeBSD binary. To : do this, the PIPS ports use www/linuxpluginwrapper to fixup some ABI : incompatibility. umemoto-san This was exactly the hint that I needed to get things working. My brother MCP-5440CN scanner is now working (don't know about the printing side of things, since I've not tried that at all). Thank you so very much! Here's a breif outline of what I've learned: (1) To remove the symbol versioning goo from a shared library, objcopy -R .gnu.version linux.so freebsd.so (there's also a .gnu.version_r on some libraries, that can also be removed this way). Doing this allows one to directly link the .so into your program, modulo ABI issues. (2) dlopen (and likely ld-elf.so in general) doesn't check the version information at all. If all you are doing is linking dynamically at run time, you don't have to perform step #1. The compile time linker, however, whines about missing symbol versions. (3) Use libmap.conf to map libc.so.6 for the shared library that you are loading to overcome ABI issues. See the man page for an example. The linuxplugwrapper port can be used to generate shims for the ABI issues, in general, and works well. I'll likely not use it for the brother scanner port I'm working on since all I need is stderr defined in a linuxly correct, and I can do that in the source part of the driver. I'd love to get the network side of things working, but I think that might be more effort than I care to go to at the moment. I'd also like to get faxing and printing working, but again, time... I bought it for the 35 sheet document feeder + scanner at $100.00 after rebate :-) Warner ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
M. Warner Losh wrote: In message: <[EMAIL PROTECTED]> Bernd Walter <[EMAIL PROTECTED]> writes: : On Tue, Aug 09, 2005 at 01:37:34PM -0600, M. Warner Losh wrote: : > I have recently purcahsed a device that comes with a .so for linux, : > but no sources. Is there any way one can take an arbitrary linux .so : > which appears to have no dependencies to a FreeBSD .so? The binary : > code is about 20k or so. : : Isn't this just brandelf'ing to FreeBSD-i386? : Asuming that the lib really has no dependencies to linux specific : device/kernel features or linux specific libs. I tried brandelfing, but that didn't work. There's some weird symbols in there: DF *UND* 0023 GLIBC_2.0 fprintf DF *UND* 00f8 GLIBC_2.0 fflush DF *UND* 01b4 GLIBC_2.0 malloc DF *UND* 0058 GLIBC_2.0 memmove DO *UND* 0004 GLIBC_2.0 stderr DF *UND* 020d GLIBC_2.0 abort DF *UND* 0027 GLIBC_2.0 memcpy w DF *UND* 00ac GLIBC_2.1.3 __cxa_finalize DF *UND* 0043 GLIBC_2.0 memset So it looks like I'm close... objcopy -R kept the GLIBC_* references in place, alas, so that didn't work, as suggested elsewhere in this thread. couldn't you make a small stub library that supplies those and link with it statically? The above list is small, but has hree bad entries: fprintf, fflush and stderr. So that may present a problem for me if these functions are ever called. Warner ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]" ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
Hi, > On Tue, 9 Aug 2005 16:31:30 -0500 > Dan Nelson <[EMAIL PROTECTED]> said: dnelson> In the last episode (Aug 09), M. Warner Losh said: > I have recently purcahsed a device that comes with a .so for linux, > but no sources. Is there any way one can take an arbitrary linux .so > which appears to have no dependencies to a FreeBSD .so? The binary > code is about 20k or so. dnelson> As long as any structs that are passed back and forth have the same dnelson> members and alignment, it should work. This includes struct FILE, dnelson> which means if the app tries to use stdio it'll likely crash. dnelson> I just compiled a little "hello world" object file on SUSE and linked dnelson> it on FreeBSD and it ran (it just calls printf, which is safe since it dnelson> doesn't pass a FILE *). As far as the Linux shlib uses the functions which ABI are compatible with FreeBSD's one, it should work. However, if there are some ABI incompatibility, you may want to consider the approach of linuxpluginwrapper. The PIPS ports (print/pips*) link Linux shlib to FreeBSD binary. To do this, the PIPS ports use www/linuxpluginwrapper to fixup some ABI incompatibility. Sincerely, -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan [EMAIL PROTECTED] [EMAIL PROTECTED],jp.}FreeBSD.org http://www.imasy.org/~ume/ ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
In message: <[EMAIL PROTECTED]> Seán C. Farley <[EMAIL PROTECTED]> writes: : Although I have never tried it, I had read somewhere that you could : possibly convert a Linux .so using objcopy. : : Found it: : http://groups-beta.google.com/group/fa.freebsd.questions/browse_frm/thread/2c1ce35fab83427/7add378b8e5a7006 : : I am curious if it works for you too. That method doesn't seem to work. I'm guessing that other options are needed these days since -R is a list of sections to remove... Warner ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
In message: <[EMAIL PROTECTED]> Bernd Walter <[EMAIL PROTECTED]> writes: : On Tue, Aug 09, 2005 at 01:37:34PM -0600, M. Warner Losh wrote: : > I have recently purcahsed a device that comes with a .so for linux, : > but no sources. Is there any way one can take an arbitrary linux .so : > which appears to have no dependencies to a FreeBSD .so? The binary : > code is about 20k or so. : : Isn't this just brandelf'ing to FreeBSD-i386? : Asuming that the lib really has no dependencies to linux specific : device/kernel features or linux specific libs. I tried brandelfing, but that didn't work. There's some weird symbols in there: DF *UND* 0023 GLIBC_2.0 fprintf DF *UND* 00f8 GLIBC_2.0 fflush DF *UND* 01b4 GLIBC_2.0 malloc DF *UND* 0058 GLIBC_2.0 memmove DO *UND* 0004 GLIBC_2.0 stderr DF *UND* 020d GLIBC_2.0 abort DF *UND* 0027 GLIBC_2.0 memcpy w DF *UND* 00ac GLIBC_2.1.3 __cxa_finalize DF *UND* 0043 GLIBC_2.0 memset So it looks like I'm close... objcopy -R kept the GLIBC_* references in place, alas, so that didn't work, as suggested elsewhere in this thread. The above list is small, but has hree bad entries: fprintf, fflush and stderr. So that may present a problem for me if these functions are ever called. Warner ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
On Tue, 09 Aug 2005 13:37:34 -0600 (MDT) "M. Warner Losh" <[EMAIL PROTECTED]> wrote: > I have recently purcahsed a device that comes with a .so for linux, > but no sources. Is there any way one can take an arbitrary linux .so > which appears to have no dependencies to a FreeBSD .so? The binary > code is about 20k or so. Could you be a bit more specific wrt dependencies? Does the device in question provide an API via said .so and a .h? You could try using ndisasm (from the /devel/nasm port) or a perl script called dasm that calls objdump and see if you can get something usable from there. If the .so is small it shouldn't be that much work, although it might be more practical to derive the interface code from the asm output (i.e. reverse engineer) than try to shoehorn the resulting .S into a FreeBSD .so. The other alternative would be building a Linux binary as Kris has suggested, although I suspect that this .so is involved in some sort of i/o which might or might not be easily ported to FreeBSD. Cheers, -- Miguel Mendez <[EMAIL PROTECTED]> http://www.energyhq.es.eu.org PGP Key: 0xDC8514F1 pgpMkjBrw2U3k.pgp Description: PGP signature
Re: Converting libfoo.so for linux to freebsd
In the last episode (Aug 09), M. Warner Losh said: > I have recently purcahsed a device that comes with a .so for linux, > but no sources. Is there any way one can take an arbitrary linux .so > which appears to have no dependencies to a FreeBSD .so? The binary > code is about 20k or so. As long as any structs that are passed back and forth have the same members and alignment, it should work. This includes struct FILE, which means if the app tries to use stdio it'll likely crash. I just compiled a little "hello world" object file on SUSE and linked it on FreeBSD and it ran (it just calls printf, which is safe since it doesn't pass a FILE *). -- Dan Nelson [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
On Tue, Aug 09, 2005 at 01:37:34PM -0600, M. Warner Losh wrote: > I have recently purcahsed a device that comes with a .so for linux, > but no sources. Is there any way one can take an arbitrary linux .so > which appears to have no dependencies to a FreeBSD .so? The binary > code is about 20k or so. Isn't this just brandelf'ing to FreeBSD-i386? Asuming that the lib really has no dependencies to linux specific device/kernel features or linux specific libs. -- B.Walter BWCThttp://www.bwct.de [EMAIL PROTECTED] [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
On Tue, 9 Aug 2005, M. Warner Losh wrote: I have recently purcahsed a device that comes with a .so for linux, but no sources. Is there any way one can take an arbitrary linux .so which appears to have no dependencies to a FreeBSD .so? The binary code is about 20k or so. Alternatively, anybody know how to take a linux .so and generate a .s that can be fed into the linux toolchain to generate a new .so... Although I have never tried it, I had read somewhere that you could possibly convert a Linux .so using objcopy. Found it: http://groups-beta.google.com/group/fa.freebsd.questions/browse_frm/thread/2c1ce35fab83427/7add378b8e5a7006 I am curious if it works for you too. Seán -- [EMAIL PROTECTED]___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
> On Tue, Aug 09, 2005 at 01:37:34PM -0600, M. Warner Losh wrote: > > I have recently purcahsed a device that comes with a .so for linux, > > but no sources. Is there any way one can take an arbitrary linux .so > > which appears to have no dependencies to a FreeBSD .so? The binary > > code is about 20k or so. > > > > Alternatively, anybody know how to take a linux .so and generate a .s > > that can be fed into the linux toolchain to generate a new .so... > > Would it be acceptable to just build your binary as a linux one? This > would be easiest. Does the Linux Sane work on FreeBSD? I thought there were issues with libusb that precluded that... Warner ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Converting libfoo.so for linux to freebsd
On Tue, Aug 09, 2005 at 01:37:34PM -0600, M. Warner Losh wrote: > I have recently purcahsed a device that comes with a .so for linux, > but no sources. Is there any way one can take an arbitrary linux .so > which appears to have no dependencies to a FreeBSD .so? The binary > code is about 20k or so. > > Alternatively, anybody know how to take a linux .so and generate a .s > that can be fed into the linux toolchain to generate a new .so... Would it be acceptable to just build your binary as a linux one? This would be easiest. Kris pgpznHtH9BmvL.pgp Description: PGP signature
Converting libfoo.so for linux to freebsd
I have recently purcahsed a device that comes with a .so for linux, but no sources. Is there any way one can take an arbitrary linux .so which appears to have no dependencies to a FreeBSD .so? The binary code is about 20k or so. Alternatively, anybody know how to take a linux .so and generate a .s that can be fed into the linux toolchain to generate a new .so... Warner ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"