    # File lib/ffi/library.rb, line 86
        def ffi_lib(*names)
          lib_flags = defined?(@ffi_lib_flags) ? @ffi_lib_flags : FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL
          ffi_libs = names.map do |name|

            if name == FFI::CURRENT_PROCESS
              FFI::DynamicLibrary.open(nil, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL)

            else
              libnames = (name.is_a?(::Array) ? name : [ name ]).map { |n| [ n, FFI.map_library_name(n) ].uniq }.flatten.compact
              lib = nil
              errors = {}

              libnames.each do |libname|
                begin
                  lib = FFI::DynamicLibrary.open(libname, lib_flags)
                  break if lib

                rescue Exception => ex
                  ldscript = false
                  if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*invalid ELF header/
                    if File.read($1) =~ /GROUP *\( *([^ \)]+) *\)/
                      libname = $1
                      ldscript = true
                    end
                  end

                  if ldscript
                    retry
                  else
                    errors[libname] = ex
                  end
                end
              end

              if lib.nil?
                raise LoadError.new(errors.values.join(".\n"))
              end

              # return the found lib
              lib
            end
          end

          @ffi_libs = ffi_libs
        end