Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6159

Get a list of all shared libraries that a running service is using in Ubuntu [closed]

$
0
0

Some solutions I found for the above problem are : (let's take an example of a running service, say /usr/sbin/acpid and say the pid of the process is 1234)

  1. ldd /usr/sbin/acpid

linux-vdso.so.1 => (0x00007ffe5eb7a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa0b1a48000)
/lib64/ld-linux-x86-64.so.2 (0x000055a297a76000)

  1. sudo objdump -p /usr/sbin/acpid | grep NEEDED

NEEDED libc.so.63. sudo pmap 12341234: /usr/sbin/acpid
0000000000400000 44K r-x-- acpid
000000000060a000 4K r---- acpid
000000000060b000 4K rw--- acpid
000000000060c000 4K rw--- [ anon ]
00000000020ce000 132K rw--- [ anon ]
00007f0ac06c7000 1788K r-x-- libc-2.23.so
00007f0ac0886000 2048K ----- libc-2.23.so
00007f0ac0a86000 16K r---- libc-2.23.so
00007f0ac0a8a000 8K rw--- libc-2.23.so
00007f0ac0a8c000 16K rw--- [ anon ]
00007f0ac0a90000 152K r-x-- ld-2.23.so
00007f0ac0caa000 12K rw--- [ anon ]
00007f0ac0cb3000 8K rw--- [ anon ]
00007f0ac0cb5000 4K r---- ld-2.23.so
00007f0ac0cb6000 4K rw--- ld-2.23.so
00007f0ac0cb7000 4K rw--- [ anon ]
00007ffcacbda000 132K rw--- [ stack ]
00007ffcacbfb000 8K r---- [ anon ]
00007ffcacbfd000 8K r-x-- [ anon ]
ffffffffff600000 4K r-x-- [ anon ]
total 4400K

  1. readelf -d /usr/sbin/acpid | grep NEEDED

0x0000000000000001 (NEEDED) Shared library: [libc.so.6]

Also in the process, I learned about what exactly are shared libraries and how are they handled in Linux on a broad level.

Now here are the things that I need help with:

  1. If we look at the output of each of the solutions above, libc.so.6 is present in the output of solutions 1, 2 and 4 but not in 3. Also the output of solution 1 above reports inux-vdso.so.1 and /lib64/ld-linux-x86-64.so.2 as well which no other solution reports. So which of these solutions should be taken as the accurate one.
  2. As per my understanding, shared libraries are loaded into the memory by the loader at runtime. Also, on demand a process can load any more shared libraries when ever needed. Am I right or wrong here ? In case right, the shared libraries being used by any given process could always be dynamic. So, if I really need to know the shared libraries being used by a process, will I need to poll the process all the time to figure this out ? (Am sure there is much better /elegant solution to this)
  3. Solution 1, the ldd approach, is something I would want to avoid because of the inherent security risk it has (depending on the version of the ldd being used) of starting an executable itself to figure out it's shared libraries.

So what is the best approach to figure out the shared libraries being used by a process?


Viewing all articles
Browse latest Browse all 6159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>