[PATCH] D36097: Prototype fix for lld DWARF parsing of base address selection entries in range lists
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 12:06:13 PDT 2017
dblaikie created this revision.
Herald added a subscriber: aprantl.
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.
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).
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.
(aside: does anyone have an idea of how well LLD scales with the number of
relocations versus the number of bytes of data in a section? I'd love to know
how much this reduction in relocations is worth (like is runtime of the linker
roughly N*relocs + M*raw bytes? Could be interesting to know - obviously
varying on different configurations (cores, disk speed, etc))
https://reviews.llvm.org/D36097
Files:
include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
include/llvm/DebugInfo/DWARF/DWARFUnit.h
lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
lib/DebugInfo/DWARF/DWARFDie.cpp
lib/DebugInfo/DWARF/DWARFUnit.cpp
Index: lib/DebugInfo/DWARF/DWARFUnit.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -242,9 +242,9 @@
// If CU DIE was just parsed, copy several attribute values from it.
if (!HasCUDie) {
DWARFDie UnitDie = getUnitDIE();
- auto BaseAddr = toAddress(UnitDie.find({DW_AT_low_pc, DW_AT_entry_pc}));
- if (BaseAddr)
- setBaseAddress(*BaseAddr);
+ const auto &LowPCDie = UnitDie.find({DW_AT_low_pc, DW_AT_entry_pc});
+ if (auto BaseAddr = toAddress(LowPCDie))
+ setBaseAddress(*BaseAddr, LowPCDie->getSectionIndex());
AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base), 0);
RangeSectionBase = toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0);
Index: lib/DebugInfo/DWARF/DWARFDie.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFDie.cpp
+++ lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -243,7 +243,8 @@
if (RangesOffset) {
DWARFDebugRangeList RangeList;
if (U->extractRangeList(*RangesOffset, RangeList))
- return RangeList.getAbsoluteRanges(U->getBaseAddress());
+ return RangeList.getAbsoluteRanges(U->getBaseAddress(),
+ U->getBaseAddressSectionIndex());
}
return DWARFAddressRangesVector();
}
Index: lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
+++ lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
@@ -62,14 +62,17 @@
}
DWARFAddressRangesVector
-DWARFDebugRangeList::getAbsoluteRanges(uint64_t BaseAddress) const {
+DWARFDebugRangeList::getAbsoluteRanges(uint64_t BaseAddress,
+ uint64_t SectionIndex) const {
DWARFAddressRangesVector Res;
for (const RangeListEntry &RLE : Entries) {
if (RLE.isBaseAddressSelectionEntry(AddressSize)) {
BaseAddress = RLE.EndAddress;
+ SectionIndex = RLE.SectionIndex;
} else {
Res.push_back({BaseAddress + RLE.StartAddress,
- BaseAddress + RLE.EndAddress, RLE.SectionIndex});
+ BaseAddress + RLE.EndAddress,
+ BaseAddress ? SectionIndex : RLE.SectionIndex});
}
}
return Res;
Index: include/llvm/DebugInfo/DWARF/DWARFUnit.h
===================================================================
--- include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -136,6 +136,7 @@
const DWARFAbbreviationDeclarationSet *Abbrevs;
uint8_t UnitType;
uint64_t BaseAddr;
+ uint64_t BaseAddrSectionIndex;
/// The compile unit debug information entry items.
std::vector<DWARFDebugInfoEntry> DieArray;
@@ -260,9 +261,11 @@
}
uint64_t getBaseAddress() const { return BaseAddr; }
+ uint64_t getBaseAddressSectionIndex() const { return BaseAddrSectionIndex; }
- void setBaseAddress(uint64_t base_addr) {
- BaseAddr = base_addr;
+ void setBaseAddress(uint64_t BaseAddr, uint64_t SectionIndex) {
+ this->BaseAddr = BaseAddr;
+ this->BaseAddrSectionIndex = SectionIndex;
}
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) {
Index: include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
===================================================================
--- include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
+++ include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
@@ -85,7 +85,8 @@
/// getAbsoluteRanges - Returns absolute address ranges defined by this range
/// list. Has to be passed base address of the compile unit referencing this
/// range list.
- DWARFAddressRangesVector getAbsoluteRanges(uint64_t BaseAddress) const;
+ DWARFAddressRangesVector getAbsoluteRanges(uint64_t BaseAddress,
+ uint64_t SectionIndex) const;
};
} // end namespace llvm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36097.108965.patch
Type: text/x-patch
Size: 3943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170731/e098e203/attachment.bin>
More information about the llvm-commits
mailing list