Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle linker scripts #117

Merged
1 commit merged into from
Aug 6, 2011
Merged

Handle linker scripts #117

1 commit merged into from
Aug 6, 2011

Conversation

aniederl
Copy link

@aniederl aniederl commented Jun 6, 2011

On some systems a .so file can be a linker script referencing the actual library .so file.

For example, /usr/lib/libncurses.so on Gentoo has this content:

/* GNU ld script
   Since Gentoo has critical dynamic libraries in /lib, and the static versions
   in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
   run into linking problems.  This "fake" dynamic lib is a linker script that
   redirects the linker to the real lib.  And yes, this works in the cross-
   compiling scenario as the sysroot-ed linker will prepend the real path.

   See bug http://bugs.gentoo.org/4411 for more info.
*/
OUTPUT_FORMAT ( elf64-x86-64 )
GROUP ( /lib64/libncurses.so.5 )

dlopen on such a .so file will produce an error:

Could not open library 'libncurses.so': /usr/lib64/libncurses.so: invalid ELF header

This commit parses the dlerror message for an "invalid ELF header" and sees if a
GROUP() command exists in the file.
If found, it tries to load the referenced file instead.

ghost pushed a commit that referenced this pull request Aug 6, 2011
Handle linker scripts on linux
@ghost ghost merged commit a558367 into ffi:master Aug 6, 2011
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant