Given a dynamically linked ELF binary, say for example
Inside the binary, there is a call to a function provided by a shared library, for example
How can I find out from which shared library/shared object the
strcp function is obtained? In other words, I want to get pairs func_name/shared_obj_name.so.
Answering this post, Michael Slade wrote:
ELF files don't specify which symbols come from which libraries; it just adds a list of shared libraries to link to into the ELF binary, and lets the linker find the symbols in the libraries.
Yet there must be a way to gather the required info (using the linker). Executing the binary and ltrace-ing it is not an option in my case. What I tried so far:
objdump -T /bin/less | grep strcpy which gives me:
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strcpy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __strcpy_chk
This is neither unambigious nor does it give me the name of a
ldd /bin/less, returning:
linux-vdso.so.1 => (0x00007ffe8b7fa000) libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f92c23a5000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f92c1fe0000) /lib64/ld-linux-x86-64.so.2 (0x00007f92c25ec000))
lets me think that the "GLIBC_2.2.5" corresponds to
How can I programmatically find the corresponding shared object (.so file) to an (imported) function?