Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement __repr__ for various classes #460

Open
disconnect3d opened this issue Feb 10, 2023 · 0 comments
Open

Implement __repr__ for various classes #460

disconnect3d opened this issue Feb 10, 2023 · 0 comments

Comments

@disconnect3d
Copy link
Contributor

disconnect3d commented Feb 10, 2023

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'>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants