ruby / fiddle

A libffi wrapper for Ruby.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't open linker script files

nevans opened this issue · comments

On my Ubuntu 21.10 installation, several shared libraries .so files are installed as linker scripts instead of using a symlink. In my research, I see that this is done (or has been done) in Debian, CentOS, Fedora, RHEL, Gentoo, and maybe Arch (I didn't personally verify the last two). This shouldn't a big deal if you link with GNU ld, but it breaks dlopen.

I found workarounds in the ffi gem and in ghc, and perhaps one of those could be copied into fiddle.

A workaround for users of fiddle might be to attempt to load a specific version of the library:

irb(main):005:0> File.read "/lib/x86_64-linux-gnu/libncurses.so"
=> "INPUT(libncurses.so.6 -ltinfo)\n"
irb(main):006:0> Fiddle::Handle.new("libncurses.so")
(irb):6:in `initialize': /lib/x86_64-linux-gnu/libncurses.so: file too short (Fiddle::DLError)
	from (irb):6:in `new'                              
	from (irb):6:in `<main>'                           
	from /home/nick/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
	from /home/nick/.rbenv/versions/3.1.1/bin/irb:25:in `load'
	from /home/nick/.rbenv/versions/3.1.1/bin/irb:25:in `<main>'
irb(main):007:0> Fiddle::Handle.new("libncurses.so.6")
=> #<Fiddle::Handle:0x00007fcfbb858670>

Hi what are you struggling to open?

I'm so sorry, I accidentally hit enter when I'd only just started creating the ticket! I was hoping I'd be able to fill in the details before anyone noticed. Anyway, I've updated the subject and I'll send a few other details over in a minute.

Thanks for your report.
I didn't know about linker script.

I've added support for linker script only on Linux for now.

Excellent, thanks!