2a492ef4723643d2d8c2e37cc5b5b568df11a3dd
[pyelftools.git] / z.py
1 # Just a script for playing around with pyelftools during testing
2 # please ignore it!
3 #
4
5 import sys, pprint
6 from elftools.elf.structs import ELFStructs
7 from elftools.elf.elffile import ELFFile
8 from elftools.elf.sections import *
9
10 # read a little-endian, 64-bit file
11 es = ELFStructs(True, 64)
12
13 stream = open('tests/testfiles/exe_simple64.elf', 'rb')
14 #stream = open('binfiles/z32.elf', 'rb')
15
16 efile = ELFFile(stream)
17 print efile.elfclass, efile.little_endian
18 print '===> %s sections!' % efile.num_sections()
19
20 #~ print efile.has_dwarf_info()
21
22 #~ dwarfinfo = efile.get_dwarf_info()
23
24 #~ cu = dwarfinfo.get_CU(3)
25 #~ print 'CU header', cu.header
26 #~ topdie = cu.get_top_DIE()
27
28 #~ c = topdie.iter_children().next()
29
30 #~ print c
31
32 #~ print 'siblings.....'
33
34 #~ for s in c.iter_siblings():
35 #~ print s
36
37 from elftools.dwarf.location_expr import DW_OP_name2opcode, DW_OP_opcode2name
38
39 print hex(DW_OP_name2opcode['DW_OP_lit14'])
40 print DW_OP_opcode2name[0x0e]
41
42