I am not sure how to capture the libraries loaded dynamically by different applications {ie: Irrespective of application }. I am trying to write a tool where in i required to log library names which are loaded dynamically into the system. Do we have any API to do that ?.
3 Answers
Sure, hack ld-linux(8) (and/or ld.so(8)) to log when it loads libraries.

- 2,089
- 13
- 14
-
-
When what you're trying to do in the first place is a horrible hack, why do you want a solution that's not a hack? – R.. GitHub STOP HELPING ICE Feb 13 '12 at 16:05
You could intercept the call to the dynamic loader, do your stuff and then chain the call to the real loader.
You can discover where is your loader with the command:
$ objdump -s -j .interp /bin/ls
(/bin/ls
is just a sample application).
Other option would be to set the environment variables LD_DEBUG
and LD_DEBUG_OUTPUT
and interpret the text that is written in the debugging output (see man ld.so
for more information).
Yet another option would be to read the /proc/*/maps
files periodically and interpret the sahred files there.

- 94,151
- 12
- 143
- 190
You could also use the /proc pseudo-file system. (See also this). With /proc/1234/maps
etc etc you can find out which files are mmap
-ed...
And of course, you have the LD_PRELOAD trick

- 1
- 1

- 223,805
- 18
- 296
- 547