0

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

Whoami
  • 13,930
  • 19
  • 84
  • 140
  • Do you want to know all the shared libraries in use by some (or all ) running applications, or do you want to catch the loading of shared libraries? – Basile Starynkevitch Feb 13 '12 at 18:42

3 Answers3

0

Sure, hack ld-linux(8) (and/or ld.so(8)) to log when it loads libraries.

tbert
  • 2,089
  • 13
  • 14
0

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.

rodrigo
  • 94,151
  • 12
  • 143
  • 190
0

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

Community
  • 1
  • 1
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547