annotate python/readelf.py @ 119:f51791638cae

Simplified flashing
author Windel Bouwman
date Sat, 12 Jan 2013 10:23:33 +0100
parents db8aafe00d27
children bbf4c9b138d4
rev   line source
118
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
1 #!/usr/bin/python
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
2
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
3 import elffile, argparse
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
4
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
5 parser = argparse.ArgumentParser()
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
6 parser.add_argument('file', type=argparse.FileType('rb'))
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
7 parser.add_argument('-l', action='store_const', const=True, default=False, dest='list_program_headers')
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
8
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
9 args = parser.parse_args()
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
10 print(args)
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
11 ef = elffile.ElfFile(args.file)
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
12 print(ef)
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
13
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
14 if args.list_program_headers:
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
15 print('program headers')
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
16 ef.printProgramHeaders()
db8aafe00d27 Added elf file read scripts
Windel Bouwman
parents:
diff changeset
17