s += _DESCR_SYMINFO_FLAGS[flag] if (x & flag) else ''
return s
+def describe_symbol_boundto(x):
+ return _DESCR_SYMINFO_BOUNDTO.get(x, '%3s' % x)
+
#-------------------------------------------------------------------------------
_unknown = '<unknown>'
SYMINFO_FLAGS.SYMINFO_FLG_DEFERRED: 'P',
}
+_DESCR_SYMINFO_BOUNDTO = dict(
+ SYMINFO_BT_SELF='<self>',
+ SYMINFO_BT_PARENT='<parent>',
+ SYMINFO_BT_NONE='',
+ SYMINFO_BT_EXTERN='<extern>',
+)
+
_DESCR_RELOC_TYPE_i386 = dict(
(v, k) for k, v in iteritems(ENUM_RELOC_TYPE_i386))
_default_=Pass,
)
+# Syminfo Bound To special values
+ENUM_SYMINFO_BOUNDTO = dict(
+ SYMINFO_BT_SELF=0xffff,
+ SYMINFO_BT_PARENT=0xfffe,
+ SYMINFO_BT_NONE=0xfffd,
+ SYMINFO_BT_EXTERN=0xfffc,
+ _default_=Pass,
+)
+
def _create_syminfo(self):
self.Elf_Syminfo = Struct('Elf_Syminfo',
- self.Elf_half('si_boundto'),
+ Enum(self.Elf_half('si_boundto'), **ENUM_SYMINFO_BOUNDTO),
self.Elf_half('si_flags'),
)
describe_sh_type, describe_sh_flags,
describe_symbol_type, describe_symbol_bind, describe_symbol_visibility,
describe_symbol_shndx, describe_reloc_type, describe_dyn_tag,
- describe_syminfo_flags,
+ describe_syminfo_flags, describe_symbol_boundto,
)
from elftools.dwarf.dwarfinfo import DWARFInfo
from elftools.dwarf.descriptions import (
index = ''
if syminfo['si_flags'] & SYMINFO_FLAGS.SYMINFO_FLG_CAP:
boundto = '<symbol capabilities>'
- elif syminfo['si_boundto'] == 0xffff:
- boundto = '<self>'
- elif syminfo['si_boundto'] == 0xfffe:
- boundto = '<parent>'
- elif syminfo['si_boundto'] == 0xfffc:
- boundto = '<extern>'
- elif syminfo['si_boundto'] == 0xfffd:
- boundto = ''
+ elif not isinstance(syminfo['si_boundto'], int):
+ boundto = describe_symbol_boundto(syminfo['si_boundto'])
else:
dyn_tag = dyntable.get_tag(syminfo['si_boundto'])
if syminfo['si_flags'] & SYMINFO_FLAGS.SYMINFO_FLG_FILTER: