From: Eli Bendersky Date: Tue, 27 Dec 2011 04:51:20 +0000 (+0200) Subject: a bit progress on locationlists X-Git-Tag: v0.10~5 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=54ff260e99e42183830de2415cd93cc1d6e044b9;p=pyelftools.git a bit progress on locationlists --- diff --git a/elftools/dwarf/locationlists.py b/elftools/dwarf/locationlists.py index 4ea8877..afe12e3 100644 --- a/elftools/dwarf/locationlists.py +++ b/elftools/dwarf/locationlists.py @@ -11,8 +11,34 @@ from collections import namedtuple from ..common.utils import struct_parse +LocationEntry = namedtuple('LocationEntry', 'begin_offset end_offset loc_expr') +BaseAddressEntry = namedtuple('BaseAddressEntry', 'base_address') + + class LocationLists(object): def __init__(self, stream, structs): + self._max_addr = 2 ** (self.structs.address_size * 8) - 1 + + def get_location_list_at_offset(self, offset): pass + + def iter_location_lists(self): + pass + + def _parse_location_list_from_stream(self): + lst = [] + while True: + begin_offset = struct_parse( + self.structs.Dwarf_target_addr(''), self.stream) + end_offset = struct_parse( + self.structs.Dwarf_target_addr(''), self.stream) + if begin_offset == 0 and end_offset == 0: + # End of list - we're done. + break + elif begin_offset == self._max_addr: + # base + else: + # entry... +