From: Edi Weitz
Subject: Wrong phentsize in LispWorks FLI
Date: 
Message-ID: <87n0nzylat.fsf@bird.agharta.de>
Hi!

While trying to get Paul Foley's Berkeley-DB interface (see
<http://users.actrix.co.nz/mycroft/cl.html>) to run with LispWorks
(4.2.7 pro on Linux) I arrived at this error message:

  Error: Could not register handle for external module :DBX:
   /usr/local/lib/dbx.so: ELF file's phentsize not the expected size.

What does that mean? I googled around a bit for this error message but
couldn't find anything helpful.

dbx.so is a shared library compiled with 'gcc -fPIC -shared'. CMUCL's
foreign function interface works fine with this library.

Any ideas?

Thanks,
Edi.

PS: I'm using Gentoo Linux 1.2 - kernel is 2.4.19, glibc is 2.2.5 - if
    that matters.

PPS: I sent this question to the LW mailing list but got no answer, so
     I'm trying it again here.

From: Eric Marsden
Subject: Re: Wrong phentsize in LispWorks FLI
Date: 
Message-ID: <wzilm3j0wsc.fsf@melbourne.laas.fr>
>>>>> "ew" == Edi Weitz <···@agharta.de> writes:

  ew> Error: Could not register handle for external module :DBX:
  ew> /usr/local/lib/dbx.so: ELF file's phentsize not the expected size.

  ew> dbx.so is a shared library compiled with 'gcc -fPIC -shared'. CMUCL's
  ew> foreign function interface works fine with this library.

the error message comes from dlopen() from the glibc. The CMUCL FFI is
probably loading the library directly using the linker, instead of
going through dlopen(), which may explain the difference in behaviour.

Try creating your shared library in two steps:

   gcc -fPIC -c dbx.c
   ld -shared dbx.o -o dbx.so

If that works, it sounds like a bug in the way that GCC is passing
arguments to the linker.
  
-- 
Eric Marsden                          <URL:http://www.laas.fr/~emarsden/>
From: Ed L Cashin
Subject: Re: Wrong phentsize in LispWorks FLI
Date: 
Message-ID: <87k7j2sr2w.fsf@cs.uga.edu>
Eric Marsden <········@laas.fr> writes:

> >>>>> "ew" == Edi Weitz <···@agharta.de> writes:
> 
>   ew> Error: Could not register handle for external module :DBX:
>   ew> /usr/local/lib/dbx.so: ELF file's phentsize not the expected size.
> 
>   ew> dbx.so is a shared library compiled with 'gcc -fPIC -shared'. CMUCL's
>   ew> foreign function interface works fine with this library.
> 
> the error message comes from dlopen() from the glibc. The CMUCL FFI is
> probably loading the library directly using the linker, instead of
> going through dlopen(), which may explain the difference in behaviour.
> 
> Try creating your shared library in two steps:
> 
>    gcc -fPIC -c dbx.c
>    ld -shared dbx.o -o dbx.so
> 
> If that works, it sounds like a bug in the way that GCC is passing
> arguments to the linker.

This is the error I see when trying to call dlopen on a regular object
file: 

  ·······@meili test-dlopen$ gcc -fPIC -W -Wall -g -c dl.c
  ·······@meili test-dlopen$ cp dl.o dl.so 
  ·······@meili test-dlopen$ ./testp > /dev/null
  Error: dlopen could not load dl.so: dl.so: ELF file's phentsize not the expected size

You probably already know that using ar won't work.  These commands
work on my debain woody PC.  The second command runs the linker via
gcc.

  gcc -fPIC -g -c -W -Wall dl.c
  gcc -shared -nostdlib -Wl,-soname,dl.so -o dl.so dl.o

I need the -nostdlib option because dl.o has a function called _init
which is run on dlopen.  It conflicts with another _init in the C
runtime. 

-- 
--Ed L Cashin            |   PGP public key:
  ·······@uga.edu        |   http://noserose.net/e/pgp/