public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] [OT] How to add library to dynamically linked executable?
@ 2015-06-22 16:13 Grant Edwards
  2015-06-22 17:16 ` Matti Nykyri
  2015-06-22 17:34 ` [gentoo-user] " Bryan Gardiner
  0 siblings, 2 replies; 6+ messages in thread
From: Grant Edwards @ 2015-06-22 16:13 UTC (permalink / raw
  To: gentoo-user

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" ...



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-06-23  0:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-22 16:13 [gentoo-user] [OT] How to add library to dynamically linked executable? Grant Edwards
2015-06-22 17:16 ` Matti Nykyri
2015-06-22 23:57   ` [gentoo-user] " walt
2015-06-23  0:31     ` Grant Edwards
2015-06-22 17:34 ` [gentoo-user] " Bryan Gardiner
2015-06-22 18:59   ` [gentoo-user] " Grant Edwards

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox