Eli Bendersky | c4a4c07 | 2011-09-17 15:28:28 +0300 | [diff] [blame] | 1 | # Just a script for playing around with pyelftools during testing |
| 2 | # please ignore it! |
| 3 | # |
| 4 | |
eliben | c6db4c4 | 2011-09-20 16:03:59 +0300 | [diff] [blame] | 5 | import sys, pprint |
Eli Bendersky | e0735d5 | 2011-09-08 20:12:44 +0300 | [diff] [blame] | 6 | from elftools.elf.structs import ELFStructs |
| 7 | from elftools.elf.elffile import ELFFile |
| 8 | from elftools.elf.sections import * |
| 9 | |
Eli Bendersky | ef943b7 | 2011-11-23 16:01:52 +0200 | [diff] [blame] | 10 | from elftools.elf.relocation import * |
Eli Bendersky | ddeedc4 | 2011-11-18 05:55:06 +0200 | [diff] [blame] | 11 | |
Eli Bendersky | e0735d5 | 2011-09-08 20:12:44 +0300 | [diff] [blame] | 12 | |
Eli Bendersky | 1b69efc | 2011-12-20 06:45:00 +0200 | [diff] [blame] | 13 | stream = open('test/testfiles/exe_simple64.elf', 'rb') |
Eli Bendersky | e0735d5 | 2011-09-08 20:12:44 +0300 | [diff] [blame] | 14 | |
| 15 | efile = ELFFile(stream) |
eliben | 985c2c1 | 2011-11-14 17:53:23 +0200 | [diff] [blame] | 16 | print 'elfclass', efile.elfclass |
Eli Bendersky | e0735d5 | 2011-09-08 20:12:44 +0300 | [diff] [blame] | 17 | print '===> %s sections!' % efile.num_sections() |
Eli Bendersky | 1b69efc | 2011-12-20 06:45:00 +0200 | [diff] [blame] | 18 | print efile.header |
Eli Bendersky | 90a3f6b | 2011-12-28 06:37:16 +0200 | [diff] [blame] | 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) |
Eli Bendersky | 26e41c4 | 2011-12-28 09:21:14 +0200 | [diff] [blame] | 24 | for loclist in llists.iter_location_lists(): |
| 25 | print '----> loclist!' |
| 26 | for li in loclist: |
| 27 | print li |
| 28 | print describe_DWARF_expr(li.loc_expr, dinfo.structs) |
Eli Bendersky | 90a3f6b | 2011-12-28 06:37:16 +0200 | [diff] [blame] | 29 | |
| 30 | |