[PATCH] D36097: Prototype fix for lld DWARF parsing of base address selection entries in range lists

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 03:16:15 PDT 2017


grimar added a comment.

> A recent improvement to LLVM produces DWARF compliant, but (apparently)
> infrequently used range lists - using base address selection entries to
> reduce the number of relocations required (& reduce file size &
> hopefully link time)
> 
> This breaks lld's use of LLVM's libDebugInfo which isn't correctly
> tracking the section index in the presence of this kind of debug info.

Do you have any sample code/testcase/anything that shows/can help to reproduce the issue ?
(looking at implementation I think I know how to generate DWARF section content manually, but I
am not sure what should I do to reproduce issue using cpp+clang for example).

> Here's my first blush at a fix for libDebugInfo - though it does rais
> some questions and needs testing (is there any testing in LLVM (not lld)
> for the section index API in libDebugInfo? it'd be good if there was,
> maybe API level testing).

I do not think we have. That looks to be my fault, I don't think I added
LLVM testcase when implemented section index API. 
I'll check what can I do for it.



================
Comment at: lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp:75
+                     BaseAddress + RLE.EndAddress,
+                     BaseAddress ? SectionIndex : RLE.SectionIndex});
     }
----------------
>How should/does this differentiate between the case where the unit's
>base address is actually zero? compared to when it's not present? Does
>that matter? I'm not sure.

So DWARF spec says:
//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 (see Section
3.1.1).//

Should `BaseAddress` and `SectionIndex` be optional then ? Then code can be like following probably:

```
DWARFAddressRangesVector
DWARFDebugRangeList::getAbsoluteRanges(Optional<uint64_t> BaseAddress,
                                        Optional<uint64_t> BaseSectionIndex) const {
  DWARFAddressRangesVector Res;
  for (const RangeListEntry &RLE : Entries) {
    if (RLE.isBaseAddressSelectionEntry(AddressSize)) {
      BaseAddress = RLE.EndAddress;
      BaseSectionIndex = RLE.SectionIndex;
      continue;
    } 

    uint64_t Start = RLE.StartAddress;
    uint64_t End = RLE.EndAddress;
    uint64_t SectionIndex = RLE.SectionIndex;
    if (BaseAddress) {
      Start  += *BaseAddress;
      End += *BaseAddress;
      SectionIndex = *BaseSectionIndex;
    }

    Res.push_back({Start, End, SectionIndex });
  }
}
```



https://reviews.llvm.org/D36097





More information about the llvm-commits mailing list