Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] [OT] How to add library to dynamically linked executable?
Date: Mon, 22 Jun 2015 16:14:18
Message-Id: mm9c85$tre$1@ger.gmane.org
1 Is there any way to add a library to the list of libraries required by
2 an ELF dynamically linked executable?
3
4 I have an executable (let's call it "foo") which was written and built
5 by somebody else [I don't have sources]. It requires the librt to run
6 on one particular platform, but librt isn't in the exeuctable's list
7 of libraries. [I'll skip the story of how it ended up this way. It
8 will be fixed with the next version of that application.]
9
10 # foo
11 foo: can't resolve symbol 'shm_open'
12
13 If I run it like this, it's fine:
14
15 # LD_PRELOAD=/lib/librt.so.0 foo
16
17 Is there any way to fix the ELF executable file to add librt.so.0 to
18 its list of libraries?
19
20 I'm aware I can create a shell script that does this:
21
22 #!/bin/sh
23 export LD_PRELOAD=/lib/librt.so.0
24 exec foo
25
26 What I'm wondering about is whether there is a way to fix the ELF
27 executable file itself so as to add librt.so.0 to its list of shared
28 libraries. I've found chrpath(1), but it only changes the search path
29 used to look for libraires, not the list of libraries themselves.
30
31 --
32 Grant Edwards grant.b.edwards Yow! Okay ... I'm going
33 at home to write the "I HATE
34 gmail.com RUBIK's CUBE HANDBOOK FOR
35 DEAD CAT LOVERS" ...

Replies