Is there any way to add a library to the list of libraries required by
an ELF dynamically linked executable?

I have an executable (let's call it "foo") which was written and built
by somebody else [I don't have sources].  It requires the librt to run
on one particular platform, but librt isn't in the exeuctable's list
of libraries.  [I'll skip the story of how it ended up this way. It
will be fixed with the next version of that application.]

  # foo
  foo: can't resolve symbol 'shm_open'
  
If I run it like this, it's fine:

  # LD_PRELOAD=/lib/librt.so.0 foo

Is there any way to fix the ELF executable file to add librt.so.0 to
its list of libraries?

I'm aware I can create a shell script that does this:

#!/bin/sh
export LD_PRELOAD=/lib/librt.so.0
exec foo

What I'm wondering about is whether there is a way to fix the ELF
executable file itself so as to add librt.so.0 to its list of shared
libraries.  I've found chrpath(1), but it only changes the search path
used to look for libraires, not the list of libraries themselves.

-- 
Grant Edwards               grant.b.edwards        Yow! Okay ... I'm going
                                  at               home to write the "I HATE
                              gmail.com            RUBIK's CUBE HANDBOOK FOR
                                                   DEAD CAT LOVERS" ...


Reply via email to