ffi/ffi — pull request #290 by jeffwilliams (2013-10-29 19:51:08+00:00)
Title: Improve loading of linker script .so files

On my debian system the ncurses .so files in /usr/lib/i386-linux-gnu/ are GNU ld linker scripts that use the INPUT directive. For example:

$ cat /usr/lib/i386-linux-gnu/libncursesw.so
INPUT(libncursesw.so.5 -ltinfo)

As well on my system, dlopen was returning "file too short" instead of "invalid ELF header". This fix should correct both issues. The original fix for this issue seems to have been inspired by a previous fix for the same issue in the Glasgow Haskel Compiler by Howard B. Golden:

http://ghc.haskell.org/trac/ghc/ticket/2615

It seems like the original fix by Howard and as implemented by Andreas Niederl handles the error 'invalid ELF header' but not 'file too short'. Later Howard B. Golden improved the fix to handle the 'file too short' error as well:

https://mail.python.org/pipermail/python-dev/2011-September/113568.html

This change uses the same corrected Regex that Howard added.