location lists kinda working. need more docs & readelf support
[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 from elftools.elf.relocation import *
11
12
13 stream = open('test/testfiles/exe_simple64.elf', 'rb')
14
15 efile = ELFFile(stream)
16 print 'elfclass', efile.elfclass
17 print '===> %s sections!' % efile.num_sections()
18 print efile.header
19
20 dinfo = efile.get_dwarf_info()
21 from elftools.dwarf.locationlists import LocationLists
22 from elftools.dwarf.descriptions import describe_DWARF_expr
23 llists = LocationLists(dinfo.debug_loc_sec.stream, dinfo.structs)
24 for li in llists.get_location_list_at_offset(0):
25 print li
26 print describe_DWARF_expr(li.loc_expr, dinfo.structs)
27
28