Skip to content
Search

Readelf

lastmod 2024-10-23created 2016-02-016 edits

Dynamic section

runpath

The path used to find libraries, referred to as RUNPATH or RPATH.

Reading an executable with something like readelf -d ./answer-jet:

Dynamic section at offset 0x12fd50 contains 39 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libgstreamer-1.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libgobject-2.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libglib-2.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libgstapp-1.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libnvdsgst_helper.so]
 0x0000000000000001 (NEEDED)             Shared library: [libnvdsgst_meta.so]
 0x0000000000000001 (NEEDED)             Shared library: [libgstrtspserver-1.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]
 0x000000000000001d (RUNPATH)            Library runpath: [/root/Project/answer-jet/build/external/local/lib:/opt/nvidia/deepstream/deepstream/lib]
 0x000000000000000c (INIT)               0xf000
 0x000000000000000d (FINI)               0xdc1e4
 0x0000000000000019 (INIT_ARRAY)         0x12c000
 0x000000000000001b (INIT_ARRAYSZ)       56 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x12c038
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x3d8
 0x0000000000000005 (STRTAB)             0x2578
 0x0000000000000006 (SYMTAB)             0x490
 0x000000000000000a (STRSZ)              9170 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x131000
 0x0000000000000002 (PLTRELSZ)           7608 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0xcc88
 0x0000000000000007 (RELA)               0x4d98
 0x0000000000000008 (RELASZ)             32496 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000000000001e (FLAGS)              BIND_NOW
 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
 0x000000006ffffffe (VERNEED)            0x4c08
 0x000000006fffffff (VERNEEDNUM)         5
 0x000000006ffffff0 (VERSYM)             0x494a
 0x000000006ffffff9 (RELACOUNT)          1280
 0x0000000000000000 (NULL)               0x0

soname

A soname gives the actual library being built, libmy.so.0.0.0, the soname libmy.so.0, so that later, when the dynamic linker (/lib/ld-linux.so.2) looks for the shared library, it finds and links the soname libmy.so.0 instead of libmy.so.0.0.0.

This allows flexible version management. The file name that gcc actually links against is libmy.so, without version information, and this too is created and used as a link file to </code>libmy.so.0.0.0</code>.

Reading a library with something like readelf -d /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstopenmpt.so prints the soname field as the SONAME entry.

Dynamic section at offset 0x6d90 contains 31 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libgstbadaudio-1.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libgstaudio-1.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libgstreamer-1.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libgobject-2.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libglib-2.0.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libopenmpt.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000e (SONAME)             Library soname: [libgstopenmpt.so]
 0x000000000000000c (INIT)               0x2000
 0x000000000000000d (FINI)               0x4848
 0x0000000000000019 (INIT_ARRAY)         0x7d10
 0x000000000000001b (INIT_ARRAYSZ)       8 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x7d18
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x2f0
 0x0000000000000005 (STRTAB)             0xa68
 0x0000000000000006 (SYMTAB)             0x318
 0x000000000000000a (STRSZ)              2178 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000003 (PLTGOT)             0x8000
 0x0000000000000002 (PLTRELSZ)           1680 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x15b0
 0x0000000000000007 (RELA)               0x13b8
 0x0000000000000008 (RELASZ)             504 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x1388
 0x000000006fffffff (VERNEEDNUM)         1
 0x000000006ffffff0 (VERSYM)             0x12ea
 0x000000006ffffff9 (RELACOUNT)          16
 0x0000000000000000 (NULL)               0x0

library dependencies

Use ldd or enter the following. The entries marked NEEDED are the library names.

$ readelf -d a.out | grep NEEDED

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

See also

Favorite site

author Zer0 sitemap