Mixing 64 and 32-bit code (was: Linking amd64 binary with a 32-bit linux library)

2008-08-07 Thread Andrea Venturoli

Kris Kennaway ha scritto:


You can't mix and match Linux and FreeBSD code in the same binary.


Sorry for stepping in, but I have a similar question I asked in the past 
and didn't get any answer:

is it possible to mix and match 32-bit and 64-bit FreeBSD code?

I have a closed source 32-bit library which I'd like to link to on a 
64-bit system...




 bye  Thanks
av.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Mixing 64 and 32-bit code (was: Linking amd64 binary with a 32-bit linux library)

2008-08-07 Thread Chuck Swiger

On Aug 7, 2008, at 12:31 PM, Andrea Venturoli wrote:

You can't mix and match Linux and FreeBSD code in the same binary.


Sorry for stepping in, but I have a similar question I asked in the  
past and didn't get any answer:

is it possible to mix and match 32-bit and 64-bit FreeBSD code?

I have a closed source 32-bit library which I'd like to link to on a  
64-bit system...


The simplest answer is that it won't work-- the syscall interface and  
function argument/return-value sizes are going to be different between  
32-bit and 64-bit code.


If you have 32-bit code compiled with -fPIC which doesn't make any  
system calls, and is using all C99 datatypes (rather than native  
datatypes like int or long which are going to change in size under  
an ILP64 environment), well, that might be linkable into a 64-bit  
binary, but even so I wouldn't count on it to work without a  
translation shim. [1]


Regards,
--
-Chuck

[1]: You can look up how thunking between Win16 and Win32 code worked  
here:


  http://en.wikipedia.org/wiki/Thunk#Thunk_as_compatibility_mapping

...but the same idea could be applied to generic 32-bit  64-bit ELF  
code.  (It's really an evil thing to try to do, however.)


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]