Skip to content

Commit

Permalink
Fix "base" calculation for rangelists.
Browse files Browse the repository at this point in the history
This fixes finding inline functions in DWARF5.

1) if there's no base in the original DIE, use the one from the root of
   the TU:

   ```The applicable base address of a range list entry is determined by
   the closest preceding base address selection entry (see below) in the
   same range list. If there is no such selection entry, then the
   applicable base address defaults to the base address of the
   compilation unit```

2) Fix base calculations for DWARFv5 which was using a local variable
   for the 'base' rather than the passed value.
  • Loading branch information
peadar committed Jun 10, 2024
1 parent 2a2a62f commit 4f46c4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion dwarf_die.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ Ranges::Ranges(const DIE &die, uintmax_t base) {
// const auto &elf = die.getUnit()->dwarf->elf;
// auto &addrs = elf->getDebugSection(".debug_addr", SHT_NULL); // XXX: would be used by the "x" ops below

uintmax_t base = 0;
auto addrlen = die.getUnit()->addrlen;
auto &unit = *die.getUnit();
for (bool done = false; !done;) {
Expand Down
6 changes: 6 additions & 0 deletions dwarf_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ Unit::findAbbreviation(size_t code) const

const std::unique_ptr<Ranges> &
Unit::getRanges(const DIE &die, uintmax_t base) {
if (base == 0) {
const DIE::Attribute & low = root().attribute(DW_AT_low_pc);
if (low.valid())
base = uintmax_t(low);

}
auto &ptr = rangesForOffset[die.offset];
if (ptr == nullptr)
ptr = std::make_unique<Ranges>(die, base);
Expand Down

0 comments on commit 4f46c4c

Please sign in to comment.