Implement __repr__ for various classes
disconnect3d opened this issue · comments
Hi,
It would be nice to add some nice __repr__
calls to different classes in elftools. That would make working with the library a bit easier.
In [1]: from elftools.elf.elffile import ELFFile
In [2]: e = ELFFile(open('./a.out', 'rb'))
In [3]: s = e.get_section_by_name('.plt')
In [4]: s
Out[4]: <elftools.elf.sections.Section at 0x7ffff12843c8>
In [5]: s.__dict__
Out[5]:
{'header': Container({'sh_name': 135, 'sh_type': 'SHT_PROGBITS', 'sh_flags': 6, 'sh_addr': 1104, 'sh_offset': 1104, 'sh_size': 96, 'sh_link': 0, 'sh_info': 0, 'sh_addralign': 16, 'sh_entsize': 4}),
'name': '.plt',
'elffile': <elftools.elf.elffile.ELFFile at 0x7ffff12cca20>,
'stream': <_io.BufferedReader name='./a.out'>,
'structs': <elftools.elf.structs.ELFStructs at 0x7ffff12cca90>,
'_compressed': 0,
'_decompressed_size': 96,
'_decompressed_align': 16}
For example, the Section
could show up as: <Section '.plt' addr=0x450 size=0x60 type='SHT_PROGBITS'>
.