From 161dd3c186e480a4fd4ef8af395f5b0845ec9d5f Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sat, 20 Oct 2018 06:02:15 +0000 Subject: DebugInfo: Use debug_addr for non-dwo addresses in DWARF 5 Putting addresses in the address pool, even with non-fission, can reduce relocations - reusing the addresses from debug_info and debug_rnglists (the latter coming soon) llvm-svn: 344834 --- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp') diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index dbac5a82b57..081163ba61f 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -195,15 +195,16 @@ DWARFDataExtractor DWARFUnit::getDebugInfoExtractor() const { getAddressByteSize()); } -bool DWARFUnit::getAddrOffsetSectionItem(uint32_t Index, - uint64_t &Result) const { +Optional +DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const { uint32_t Offset = AddrOffsetSectionBase + Index * getAddressByteSize(); if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize()) - return false; + return None; DWARFDataExtractor DA(Context.getDWARFObj(), *AddrOffsetSection, isLittleEndian, getAddressByteSize()); - Result = DA.getRelocatedAddress(&Offset); - return true; + uint64_t Section; + uint64_t Address = DA.getRelocatedAddress(&Offset, &Section); + return {{Address, Section}}; } bool DWARFUnit::getStringOffsetSectionItem(uint32_t Index, @@ -401,8 +402,10 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) { if (!isDWO) { assert(AddrOffsetSectionBase == 0); assert(RangeSectionBase == 0); - AddrOffsetSectionBase = - toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base), 0); + AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_addr_base), 0); + if (!AddrOffsetSectionBase) + AddrOffsetSectionBase = + toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base), 0); RangeSectionBase = toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0); } @@ -760,15 +763,13 @@ const DWARFAbbreviationDeclarationSet *DWARFUnit::getAbbreviations() const { return Abbrevs; } -llvm::Optional DWARFUnit::getBaseAddress() { +llvm::Optional DWARFUnit::getBaseAddress() { if (BaseAddr) return BaseAddr; DWARFDie UnitDie = getUnitDIE(); Optional PC = UnitDie.find({DW_AT_low_pc, DW_AT_entry_pc}); - if (Optional Addr = toAddress(PC)) - BaseAddr = {*Addr, PC->getSectionIndex()}; - + BaseAddr = toSectionedAddress(PC); return BaseAddr; } -- cgit v1.2.3