For a shared object which is compiled for ARM, calling readelf with -a option, displays libraries without version numbers, i.e. libc.so
me@home:~ $ readelf -a shared_object_for_arm | grep "Shared library"
Type: DYN (Shared object file)
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libGLESv1_CM.so]
0x00000001 (NEEDED) Shared library: [libz.so]
0x00000001 (NEEDED) Shared library: [liblog.so]
However, when I reapeat same things for a shared object in the system, version numbers are displayed. I also used arm-linux-gnueabi-readlef for the above situation but nothing is changed. I am trying this in a x86 system.
me@home:~ $ readelf -a /usr/lib/libsnmp.so.15 | grep "Shared library"
Type: DYN (Shared object file)
0x00000001 (NEEDED) Shared library: [libcrypto.so.1.0.0]
0x00000001 (NEEDED) Shared library: [libc.so.6]
Is there any other way than readelf to display version numbers?
You may try eu-readelf from elfutils, but IMHO both just dump whatever is there. If DT_NEEDED entry does not contain string with version, it’s without version. Dynamic section of shared object contains similar DT_SONAME entry. SONAME or Shared Object NAME is some kind of canonical name for shared library (dynamic shared object).
If you compile against certain library its DT_SONAME entry is copied over into DT_NEEDED entry of binary or shared object you are creating. Upon execution dynamic linker will use DT_NEEDED entry to find a file with that name. AFAIK dynamic linker does not check that DT_SONAME entry of that file, so in theory it doesn’t have to have DT_SONAME at all or it might be different. You only have to make sure that on target system libc.so points to the right library. It might be symlik to libc.so.6, that does not matter.
To sum it up if one binary is linked against libc.so.6 and the other against libc.so, it can still work as long the actual file with those names are the same or one is the symlink to the other. If you want to check what is actually loaded at runtime ldd is your friend.