From 52a5c3e27142f93fad60e2c4ac26afba723d1e63 Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Tue, 29 Oct 2013 15:40:25 -0400 Subject: Improve loading of linker script .so files * On some versions of Linux the dlopen error message for linker scripts is "file too short" instead of "invalid ELF header". * On some Linux distributions the linker script uses the INPUT directive instead of GROUP * Sometimes the INPUT directive is followed by a library name and in addition more linker options (which we can ignore) --- lib/ffi/library.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ffi/library.rb b/lib/ffi/library.rb index fcb8046..a09cb92 100644 --- a/lib/ffi/library.rb +++ b/lib/ffi/library.rb @@ -135,8 +135,8 @@ module FFI rescue Exception => ex ldscript = false - if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*invalid ELF header/ - if File.read($1) =~ /GROUP *\( *([^ \)]+) *\)/ + if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short)/ + if File.read($1) =~ /(?:GROUP|INPUT) *\( *([^ \)]+)/ libname = $1 ldscript = true end -- cgit v1.2.1