118
|
1 #!/usr/bin/python
|
|
2
|
|
3 import elffile, argparse
|
|
4
|
|
5 parser = argparse.ArgumentParser()
|
|
6 parser.add_argument('file', type=argparse.FileType('rb'))
|
|
7 parser.add_argument('-l', action='store_const', const=True, default=False, dest='list_program_headers')
|
|
8
|
|
9 args = parser.parse_args()
|
|
10 print(args)
|
|
11 ef = elffile.ElfFile(args.file)
|
|
12 print(ef)
|
|
13
|
|
14 if args.list_program_headers:
|
|
15 print('program headers')
|
126
|
16 phs = ef.parsePrograms()
|
|
17 print(phs)
|
|
18 for ph in phs:
|
|
19 print('type=0x{0:X} vaddr=0x{1:X} filesz=0x{2:X}'.format(ph.p_type, ph.p_vaddr, ph.p_filesz))
|
118
|
20
|