the relocation manager for dwarf works! sdf
[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.dwarf.dwarfrelocationmanager import DWARFRelocationManager
11
12 # read a little-endian, 64-bit file
13 es = ELFStructs(True, 64)
14
15 stream = open('tests/testfiles/penalty_64.o.elf', 'rb')
16 #stream = open('binfiles/z32.elf', 'rb')
17
18 efile = ELFFile(stream)
19 print 'elfclass', efile.elfclass
20 print '===> %s sections!' % efile.num_sections()
21
22 #~ print efile.has_dwarf_info()
23
24 dwarfinfo = efile.get_dwarf_info()
25 print dwarfinfo.get_string_from_table(0x4bc0)
26 cu = dwarfinfo.get_CU(0)
27
28 print cu.structs.Dwarf_dw_form['DW_FORM_strp'].parse('\x01\x00\x00\x00\x01\x00\x00\x00')
29 print 'CU header', cu.header
30 topdie = cu.get_top_DIE()
31
32 print topdie
33 dinfo_sec = efile.get_section_by_name('.debug_info')
34 relman = DWARFRelocationManager(efile, dinfo_sec.name)
35
36 print relman._reloc_section.name, relman._reloc_section['sh_offset']
37 #pprint.pprint(relman._relocs)
38