""" Dynamic Tag object - representing a single dynamic tag entry from a
dynamic section.
- Similarly to Section objects, allows dictionary-like access to the
- dynamic tag.
+ Allows dictionary-like access to the dynamic structure. For special
+ tags (those listed in the _HANDLED_TAGS set below), creates additional
+ attributes for convenience. For example, .soname will contain the actual
+ value of DT_SONAME (fetched from the dynamic symbol table).
"""
-
- _HANDLED_TAGS = frozenset(['DT_NEEDED', 'DT_RPATH', 'DT_RUNPATH'])
+ _HANDLED_TAGS = frozenset(
+ ['DT_NEEDED', 'DT_RPATH', 'DT_RUNPATH', 'DT_SONAME'])
def __init__(self, entry, elffile):
self.entry = entry
class Dynamic(object):
+ """ Shared functionality between dynamic sections and segments.
+ """
def __init__(self, stream, elffile, position):
self._stream = stream
self._elffile = elffile
self._elfstructs = elffile.structs
- self._num_tags = -1;
+ self._num_tags = -1
self._offset = position
self._tagsize = self._elfstructs.Elf_Dyn.sizeof()
section.num_tags()))
self._emitline(" Tag Type Name/Value")
- hexwidth = 8 if self.elffile.elfclass == 32 else 16
padding = 20 + (8 if self.elffile.elfclass == 32 else 0)
for tag in section.iter_tags():
if tag.entry.d_tag == 'DT_NEEDED':
parsed = 'Library rpath: [%s]' % tag.rpath
elif tag.entry.d_tag == 'DT_RUNPATH':
parsed = 'Library runpath: [%s]' % tag.runpath
+ elif tag.entry.d_tag == 'DT_SONAME':
+ parsed = 'Library soname: [%s]' % tag.soname
elif (tag.entry.d_tag.endswith('SZ') or
tag.entry.d_tag.endswith('ENT')):
parsed = '%i (bytes)' % tag['d_val']
self._emitline(" %s %-*s %s" % (
self._format_hex(ENUM_D_TAG.get(tag.entry.d_tag, tag.entry.d_tag),
- fieldsize=hexwidth, lead0x=True),
+ fullhex=True, lead0x=True),
padding,
'(%s)' % (tag.entry.d_tag[3:],),
parsed))