[Python-Dev] Handling linker scripts reached when dynamically loading a module
Ben Wolfson
wolfson at gmail.com
Sun Sep 11 01:52:07 CEST 2011
On Sat, Sep 10, 2011 at 4:35 PM, Howard B. Golden
<howard_b_golden at yahoo.com> wrote:
>
> So, in Python, this is likely to only affect users calling packages
> using ctypes. (This corresponds to GHCi loading an unversioned library,
> e.g., "ghci -lm" which would load the current version of the math
> library into the GHC interpreter.)
And it does do so on Gentoo:
$ python
Python 2.6.6 (r266:84292, Dec 26 2010, 17:43:52)
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import cdll
>>> cdll.LoadLibrary('libpthread.so')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/libpthread.so: invalid ELF header
>>> cdll.LoadLibrary('libpthread.so.0')
<CDLL 'libpthread.so.0', handle b76f3798 at 9634e0c>
>>>
$ cat /usr/lib/libpthread.so
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-i386)
GROUP ( /lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a )
--
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure." [Larousse, "Drink" entry]
More information about the Python-Dev
mailing list