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