Skip to content

Commit bda683d

Browse files
committed
yet more dwarf fixes
1 parent a3cb267 commit bda683d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cle/backends/elf/elf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def _load_line_info(self, dwarf):
701701
self.addr_to_line[relocated_addr].add((str(filename), line.state.line))
702702

703703
@staticmethod
704-
def _load_ranges_form_die(die: DIE, aranges, base_addr: int = 0) -> list[tuple[int, int]] | None:
704+
def _load_ranges_form_die(die: DIE, aranges, base_addr: int | None = None) -> list[tuple[int, int]] | None:
705705
if aranges is not None and "DW_AT_ranges" in die.attributes:
706706
result = []
707707
for entry in aranges.get_range_list_at_offset(die.attributes["DW_AT_ranges"].value, die.cu):
@@ -711,6 +711,8 @@ def _load_ranges_form_die(die: DIE, aranges, base_addr: int = 0) -> list[tuple[i
711711
if entry.is_absolute:
712712
result.append((entry.begin_offset, entry.end_offset))
713713
else:
714+
if base_addr is None:
715+
base_addr = die.cu.get_top_DIE().attributes["DW_AT_low_pc"].value
714716
result.append((base_addr + entry.begin_offset, base_addr + entry.end_offset))
715717
return result
716718
return None
@@ -923,7 +925,7 @@ def _load_die_lex_block(
923925
subr.ranges.append((low_pc, high_pc))
924926
elif "DW_AT_ranges" in sub_die.attributes:
925927
aranges = dwarf.range_lists()
926-
ranges = self._load_ranges_form_die(sub_die, aranges, subprogram.low_pc)
928+
ranges = self._load_ranges_form_die(sub_die, aranges)
927929
if ranges is not None:
928930
subr.ranges = ranges
929931
if "DW_AT_abstract_origin" in sub_die.attributes:

0 commit comments

Comments
 (0)