From 3c7db13ad1e29de756f89df5ec1cdf82f5349702 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Mon, 12 Dec 2022 05:51:59 +0100 Subject: [PATCH 1/2] Add error message of newer Macos to linker script emulation and adjust the regex to match the new format of the message text. The new error message is raised in macOS-12.6.1 while macOS-11.7 worked. Fixes #981 --- lib/ffi/dynamic_library.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 5a9899dd04e2a8cac3cc52b704df0a0ec16d71b6 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Mon, 12 Dec 2022 08:19:21 +0100 Subject: [PATCH 2/2] Fix typo The test is about "linker scripts" not "loader scripts". --- spec/ffi/library_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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")