X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=z.py;h=02d4f3f8381b242bc022465f4ff0870be5cf747f;hb=bd1a09f92c4ecdffd45cc01b3847ddea4fb90701;hp=b52b969060af8e3eb246e7e24c1c03981b04eeeb;hpb=e790d0db44e5a59e806390e59a603c852f00b367;p=pyelftools.git diff --git a/z.py b/z.py index b52b969..02d4f3f 100644 --- a/z.py +++ b/z.py @@ -1,10 +1,30 @@ -from elftools.elf.structs import ELFStructs - -es = ELFStructs(True, 64) - - -stream = open('binfiles/z.elf', 'rb') -print es.Elf_Ehdr.parse_stream(stream) - - -#~ print es.Elf_Ehdr +# Just a script for playing around with pyelftools during testing +# please ignore it! +# + +import sys, pprint +from elftools.elf.structs import ELFStructs +from elftools.elf.elffile import ELFFile +from elftools.elf.sections import * + +from elftools.elf.relocation import * + + +stream = open('test/testfiles/exe_simple64.elf', 'rb') + +efile = ELFFile(stream) +print 'elfclass', efile.elfclass +print '===> %s sections!' % efile.num_sections() +print efile.header + +dinfo = efile.get_dwarf_info() +from elftools.dwarf.locationlists import LocationLists +from elftools.dwarf.descriptions import describe_DWARF_expr +llists = LocationLists(dinfo.debug_loc_sec.stream, dinfo.structs) +for loclist in llists.iter_location_lists(): + print '----> loclist!' + for li in loclist: + print li + print describe_DWARF_expr(li.loc_expr, dinfo.structs) + +