Reputation: 93
I've been trying to get static and dynamic dependencies from files. I have the source code and unstipped bin files, To get all of the dynamic dependencies I used this line and its worked
readelf -d $1 | grep "NEEDED\|RPATH" | perl -pe 's/.*\[(.*)\]/$1/
My problem is with the static libraries, when I'm using the command:
nm path/to/so
I'm getting the names of the functions and not the files. Is there any way to see the static dependencies for each binary file?
Upvotes: 0
Views: 59
Reputation: 2025
Dynamic libraries (.so) cannot have "static dependencies" as they are already linked.
Object files (.o) and static libraries (.a) define symbols that they export (to be used by others) and symbols they themselves use.
You can list the symbols of object files using the nm
command. For example:
$ nm lukas.o
U __cxa_atexit
U __dso_handle
0000000000000000 V DW.ref.__gxx_personality_v0
U _GLOBAL_OFFSET_TABLE_
00000000000003a8 t _GLOBAL__sub_I__Z15double_from_strRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
U __gxx_personality_v0
00000000000001d5 T main
U __stack_chk_fail
U _Unwind_Resume
The U
keyword marks the symbols that are undefined, that is, the static dependencies of the object file.
Upvotes: 1