diff --git a/lib/ffi/dynamic_library.rb b/lib/ffi/dynamic_library.rb index a5469c49c..3dcf8484c 100644 --- a/lib/ffi/dynamic_library.rb +++ b/lib/ffi/dynamic_library.rb @@ -74,7 +74,7 @@ def self.try_load(libname, flags, errors) # LoadError for C ext & JRuby, RuntimeError for TruffleRuby rescue LoadError, RuntimeError => ex - if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format)/ + if ex.message =~ /(([^ \t()'])+\.so([^ \t:()'])*)[:']([ \t\(])*(invalid ELF header|file too short|invalid file format|not a mach-o file)/ if File.binread($1) =~ /(?:GROUP|INPUT) *\( *([^ \)]+)/ return try_load($1, flags, errors) end diff --git a/spec/ffi/library_spec.rb b/spec/ffi/library_spec.rb index ca28974c9..296f50ea9 100644 --- a/spec/ffi/library_spec.rb +++ b/spec/ffi/library_spec.rb @@ -88,7 +88,7 @@ class StructUCDP < FFI::Struct }.to raise_error(LoadError) end - it "interprets INPUT() in loader scripts", unless: FFI::Platform.windows? do + it "interprets INPUT() in linker scripts", unless: FFI::Platform.windows? do path = File.dirname(TestLibrary::PATH) file = File.basename(TestLibrary::PATH) script = File.join(path, "ldscript.so")