summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp22
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp5
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp7
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp2
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp4
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp2
6 files changed, 31 insertions, 11 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 321e157665a..5ede9bf5961 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -1651,9 +1651,25 @@ public:
//
// TODO Don't store Resolver in every RelocAddrEntry.
if (Supports && Supports(Reloc.getType())) {
- Map->try_emplace(Reloc.getOffset(),
- RelocAddrEntry{SymInfoOrErr->SectionIndex, Reloc,
- Resolver, SymInfoOrErr->Address});
+ auto I = Map->try_emplace(
+ Reloc.getOffset(),
+ RelocAddrEntry{SymInfoOrErr->SectionIndex, Reloc,
+ SymInfoOrErr->Address,
+ Optional<object::RelocationRef>(), 0, Resolver});
+ // If we didn't successfully insert that's because we already had a
+ // relocation for that offset. Store it as a second relocation in the
+ // same RelocAddrEntry instead.
+ if (!I.second) {
+ RelocAddrEntry &entry = I.first->getSecond();
+ if (entry.Reloc2) {
+ ErrorPolicy EP = HandleError(createError(
+ "At most two relocations per offset are supported"));
+ if (EP == ErrorPolicy::Halt)
+ return;
+ }
+ entry.Reloc2 = Reloc;
+ entry.SymbolValue2 = SymInfoOrErr->Address;
+ }
} else {
SmallString<32> Type;
Reloc.getTypeName(Type);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
index 6f2f992f53e..b9adf8cb1d9 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
@@ -24,7 +24,10 @@ uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint32_t *Off,
return A;
if (SecNdx)
*SecNdx = E->SectionIndex;
- return E->Resolver(E->Reloc, E->SymbolValue, A);
+ uint64_t R = E->Resolver(E->Reloc, E->SymbolValue, A);
+ if (E->Reloc2)
+ R = E->Resolver(*E->Reloc2, E->SymbolValue2, R);
+ return R;
}
Optional<uint64_t>
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 3ee5652a0eb..a1cb1e8582e 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -300,7 +300,7 @@ Error DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData,
const uint64_t PrologueOffset = *OffsetPtr;
clear();
- TotalLength = DebugLineData.getU32(OffsetPtr);
+ TotalLength = DebugLineData.getRelocatedValue(4, OffsetPtr);
if (TotalLength == UINT32_MAX) {
FormParams.Format = dwarf::DWARF64;
TotalLength = DebugLineData.getU64(OffsetPtr);
@@ -325,7 +325,8 @@ Error DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData,
SegSelectorSize = DebugLineData.getU8(OffsetPtr);
}
- PrologueLength = DebugLineData.getUnsigned(OffsetPtr, sizeofPrologueLength());
+ PrologueLength =
+ DebugLineData.getRelocatedValue(sizeofPrologueLength(), OffsetPtr);
const uint64_t EndPrologueOffset = PrologueLength + *OffsetPtr;
MinInstLength = DebugLineData.getU8(OffsetPtr);
if (getVersion() >= 4)
@@ -754,7 +755,7 @@ Error DWARFDebugLine::LineTable::parse(
// requires the use of DW_LNS_advance_pc. Such assemblers, however,
// can use DW_LNS_fixed_advance_pc instead, sacrificing compression.
{
- uint16_t PCOffset = DebugLineData.getU16(OffsetPtr);
+ uint16_t PCOffset = DebugLineData.getRelocatedValue(2, OffsetPtr);
State.Row.Address.Address += PCOffset;
if (OS)
*OS
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index b3e4c911b5a..290d35511cd 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -299,7 +299,7 @@ bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
case DW_FORM_data8:
case DW_FORM_ref8:
case DW_FORM_ref_sup8:
- Value.uval = Data.getU64(OffsetPtr);
+ Value.uval = Data.getRelocatedValue(8, OffsetPtr);
break;
case DW_FORM_data16:
// Treat this like a 16-byte block.
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
index 32bb6d329ae..e38e706227d 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
@@ -25,7 +25,7 @@ Error DWARFListTableHeader::extract(DWARFDataExtractor Data,
"%s table length at offset 0x%" PRIx32,
SectionName.data(), *OffsetPtr);
// TODO: Add support for DWARF64.
- HeaderData.Length = Data.getU32(OffsetPtr);
+ HeaderData.Length = Data.getRelocatedValue(4, OffsetPtr);
if (HeaderData.Length == 0xffffffffu)
return createStringError(errc::not_supported,
"DWARF64 is not supported in %s at offset 0x%" PRIx32,
@@ -73,7 +73,7 @@ Error DWARFListTableHeader::extract(DWARFDataExtractor Data,
SectionName.data(), HeaderOffset, HeaderData.OffsetEntryCount);
Data.setAddressSize(HeaderData.AddrSize);
for (uint32_t I = 0; I < HeaderData.OffsetEntryCount; ++I)
- Offsets.push_back(Data.getU32(OffsetPtr));
+ Offsets.push_back(Data.getRelocatedValue(4, OffsetPtr));
return Error::success();
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 94bfc8c148f..b74acf60c74 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -241,7 +241,7 @@ bool DWARFUnitHeader::extract(DWARFContext &Context,
IndexEntry = Entry;
if (!IndexEntry && Index)
IndexEntry = Index->getFromOffset(*offset_ptr);
- Length = debug_info.getU32(offset_ptr);
+ Length = debug_info.getRelocatedValue(4, offset_ptr);
FormParams.Format = DWARF32;
unsigned SizeOfLength = 4;
if (Length == 0xffffffff) {
OpenPOWER on IntegriCloud