Mercurial > lcfOS
view python/readelf.py @ 222:c3f1ce8b638f
Fixup of parser
author | Windel Bouwman |
---|---|
date | Tue, 09 Jul 2013 17:36:31 +0200 |
parents | bbf4c9b138d4 |
children |
line wrap: on
line source
#!/usr/bin/python import elffile, argparse parser = argparse.ArgumentParser() parser.add_argument('file', type=argparse.FileType('rb')) parser.add_argument('-l', action='store_const', const=True, default=False, dest='list_program_headers') args = parser.parse_args() print(args) ef = elffile.ElfFile(args.file) print(ef) if args.list_program_headers: print('program headers') phs = ef.parsePrograms() print(phs) for ph in phs: print('type=0x{0:X} vaddr=0x{1:X} filesz=0x{2:X}'.format(ph.p_type, ph.p_vaddr, ph.p_filesz))