1 #-------------------------------------------------------------------------------
4 # Eli Bendersky (eliben@gmail.com)
5 # This code is in the public domain
6 #-------------------------------------------------------------------------------
8 # Just a script for playing around with pyelftools during testing
11 from __future__
import print_function
14 from elftools
.elf
.structs
import ELFStructs
15 from elftools
.elf
.elffile
import ELFFile
16 from elftools
.elf
.sections
import *
18 from elftools
.elf
.relocation
import *
21 stream
= open('test/testfiles/exe_simple64.elf', 'rb')
23 efile
= ELFFile(stream
)
24 print('elfclass', efile
.elfclass
)
25 print('===> %s sections!' % efile
.num_sections())
28 dinfo
= efile
.get_dwarf_info()
29 from elftools
.dwarf
.locationlists
import LocationLists
30 from elftools
.dwarf
.descriptions
import describe_DWARF_expr
31 llists
= LocationLists(dinfo
.debug_loc_sec
.stream
, dinfo
.structs
)
32 for loclist
in llists
.iter_location_lists():
33 print('----> loclist!')
36 print(describe_DWARF_expr(li
.loc_expr
, dinfo
.structs
))