summaryrefslogtreecommitdiff
path: root/lib/DebugInfo/DWARF/DWARFUnit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/DebugInfo/DWARF/DWARFUnit.cpp')
-rw-r--r--lib/DebugInfo/DWARF/DWARFUnit.cpp42
1 files changed, 15 insertions, 27 deletions
diff --git a/lib/DebugInfo/DWARF/DWARFUnit.cpp b/lib/DebugInfo/DWARF/DWARFUnit.cpp
index fd9c7c2b1d46c..043bdb874f431 100644
--- a/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -32,8 +32,7 @@ using namespace dwarf;
void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) {
parseImpl(C, Section, C.getDebugAbbrev(), &C.getRangeSection(),
C.getStringSection(), C.getStringOffsetSection(),
- &C.getAddrSection(), C.getLineSection().Data, C.isLittleEndian(),
- false);
+ &C.getAddrSection(), C.getLineSection(), C.isLittleEndian(), false);
}
void DWARFUnitSectionBase::parseDWO(DWARFContext &C,
@@ -41,15 +40,15 @@ void DWARFUnitSectionBase::parseDWO(DWARFContext &C,
DWARFUnitIndex *Index) {
parseImpl(C, DWOSection, C.getDebugAbbrevDWO(), &C.getRangeDWOSection(),
C.getStringDWOSection(), C.getStringOffsetDWOSection(),
- &C.getAddrSection(), C.getLineDWOSection().Data, C.isLittleEndian(),
+ &C.getAddrSection(), C.getLineDWOSection(), C.isLittleEndian(),
true);
}
DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
const DWARFDebugAbbrev *DA, const DWARFSection *RS,
StringRef SS, const DWARFSection &SOS,
- const DWARFSection *AOS, StringRef LS, bool LE, bool IsDWO,
- const DWARFUnitSectionBase &UnitSection,
+ const DWARFSection *AOS, const DWARFSection &LS, bool LE,
+ bool IsDWO, const DWARFUnitSectionBase &UnitSection,
const DWARFUnitIndex::Entry *IndexEntry)
: Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS),
LineSection(LS), StringSection(SS), StringOffsetSection(SOS),
@@ -65,33 +64,23 @@ bool DWARFUnit::getAddrOffsetSectionItem(uint32_t Index,
uint32_t Offset = AddrOffsetSectionBase + Index * getAddressByteSize();
if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize())
return false;
- DataExtractor DA(AddrOffsetSection->Data, isLittleEndian,
- getAddressByteSize());
- Result = getRelocatedValue(DA, getAddressByteSize(), &Offset,
- &AddrOffsetSection->Relocs);
+ DWARFDataExtractor DA(*AddrOffsetSection, isLittleEndian,
+ getAddressByteSize());
+ Result = DA.getRelocatedAddress(&Offset);
return true;
}
bool DWARFUnit::getStringOffsetSectionItem(uint32_t Index,
uint64_t &Result) const {
- unsigned ItemSize = getFormat() == DWARF64 ? 8 : 4;
+ unsigned ItemSize = getDwarfOffsetByteSize();
uint32_t Offset = StringOffsetSectionBase + Index * ItemSize;
if (StringOffsetSection.Data.size() < Offset + ItemSize)
return false;
- DataExtractor DA(StringOffsetSection.Data, isLittleEndian, 0);
- Result = ItemSize == 4 ? DA.getU32(&Offset) : DA.getU64(&Offset);
+ DWARFDataExtractor DA(StringOffsetSection, isLittleEndian, 0);
+ Result = DA.getRelocatedValue(ItemSize, &Offset);
return true;
}
-uint64_t DWARFUnit::getStringOffsetSectionRelocation(uint32_t Index) const {
- unsigned ItemSize = getFormat() == DWARF64 ? 8 : 4;
- uint64_t ByteOffset = StringOffsetSectionBase + Index * ItemSize;
- RelocAddrMap::const_iterator AI = getStringOffsetsRelocMap().find(ByteOffset);
- if (AI != getStringOffsetsRelocMap().end())
- return AI->second.Value;
- return 0;
-}
-
bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
Length = debug_info.getU32(offset_ptr);
// FIXME: Support DWARF64.
@@ -149,14 +138,13 @@ bool DWARFUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
}
bool DWARFUnit::extractRangeList(uint32_t RangeListOffset,
- DWARFDebugRangeList &RangeList) const {
+ DWARFDebugRangeList &RangeList) const {
// Require that compile unit is extracted.
assert(!DieArray.empty());
- DataExtractor RangesData(RangeSection->Data, isLittleEndian,
- getAddressByteSize());
+ DWARFDataExtractor RangesData(*RangeSection, isLittleEndian,
+ getAddressByteSize());
uint32_t ActualRangeListOffset = RangeSectionBase + RangeListOffset;
- return RangeList.extract(RangesData, &ActualRangeListOffset,
- RangeSection->Relocs);
+ return RangeList.extract(RangesData, &ActualRangeListOffset);
}
void DWARFUnit::clear() {
@@ -190,7 +178,7 @@ void DWARFUnit::extractDIEsToVector(
uint32_t DIEOffset = Offset + getHeaderSize();
uint32_t NextCUOffset = getNextUnitOffset();
DWARFDebugInfoEntry DIE;
- DataExtractor DebugInfoData = getDebugInfoExtractor();
+ DWARFDataExtractor DebugInfoData = getDebugInfoExtractor();
uint32_t Depth = 0;
bool IsCUDie = true;