Re: [Hampshire] 32bit compiled library on a 64bit system?

Top Page
Author: Hugo Mills
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] 32bit compiled library on a 64bit system?

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x58501100.hantslug.org.uk.16863': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Thu May 28 21:25:09 2009 BST
gpg: using DSA key 20ACB3BE515C238D
gpg: Can't check signature: No public key
On Thu, May 28, 2009 at 08:46:09PM +0100, David Ramsden wrote:
> I've got a 64bit Debian (Lenny) system but unfortunately I have a
> requirement where I need to run a PHP extension on this system that was
> compiled on a 32bit system. The source isn't available and the people
> who produce the extension won't recompile it.


You're probably stuffed, then.

> $ uname -a
> Linux D2-100-70251 2.6.27.10-grsec #1 SMP Wed May 20 23:47:45 BST 2009
> x86_64 GNU/Linux
>
> $ sudo tail /var/log/apache/error.log
> PHP Warning: PHP Startup: Unable to load dynamic library
> '/usr/lib/php5/20060613/php520_cybersource.so' -
> /usr/lib/php5/20060613/php520_cybersource.so: wrong ELF class:
> ELFCLASS32 in Unknown on line 0
>
> $ file /usr/lib/php5/20060613/php520_cybersource.so
> /usr/lib/php5/20060613/php520_cybersource.so: ELF 32-bit LSB shared
> object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped
>
> This PHP extension also comes with it's own libs that I've added to
> ld.so.conf.
>
> Now I'm guessing the problem is because the PHP extension was compiled
> on a 32bit system and I'm trying to run it on a 64 bit system and it's
> nothing to do with my hand rolled kernel and me missing out some kind of
> backward compatibility option?


You're correct -- you're running a 64-bit PHP, so it can't link
with the 32-bit library. The ABIs are, regrettably, totally different.

In theory, you could potentially have an assembly shim that would
convert the 64-bit PHP ABI into the 32-bit one. However, that's
probably "a bit tricky" to do. I certainly wouldn't try writing one
myself.

> I'm also guessing I'm a bit stuck and there's no work around for this? I
> can reinstall with a 32bit OS as this system is in testing but of
> course, ideally I'd like to run a 64bit OS on the 64bit processor that's
> inside the box.


You could run your PHP (and the associated app stack -- Apache) in
a 32-bit chroot, and the rest of the system in 64 bits.

Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
  --- My doctor tells me that I have a malformed public-duty gland, ---  
                and a natural deficiency in moral fibre.