diff options
Diffstat (limited to 'third_party/llvm-project')
-rw-r--r-- | third_party/llvm-project/DWARFCompileUnit.cpp | 8 | ||||
-rw-r--r-- | third_party/llvm-project/DWARFContext.cpp | 4 | ||||
-rw-r--r-- | third_party/llvm-project/DWARFDebugInfoEntry.cpp | 6 | ||||
-rw-r--r-- | third_party/llvm-project/DWARFEmitter.cpp | 18 | ||||
-rw-r--r-- | third_party/llvm-project/DWARFVisitor.cpp | 3 | ||||
-rw-r--r-- | third_party/llvm-project/dwarf2yaml.cpp | 4 |
6 files changed, 35 insertions, 8 deletions
diff --git a/third_party/llvm-project/DWARFCompileUnit.cpp b/third_party/llvm-project/DWARFCompileUnit.cpp index f59e49268..a9791f921 100644 --- a/third_party/llvm-project/DWARFCompileUnit.cpp +++ b/third_party/llvm-project/DWARFCompileUnit.cpp @@ -20,9 +20,11 @@ void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { << " version = " << format("0x%04x", getVersion()); if (getVersion() >= 5) OS << " unit_type = " << dwarf::UnitTypeString(getUnitType()); - OS << " abbr_offset = " - << format("0x%04" PRIx64, getAbbreviations()->getOffset()) - << " addr_size = " << format("0x%02x", getAddressByteSize()); + if (auto* Abbreviations = getAbbreviations()) { // XXX BINARYEN + OS << " abbr_offset = " + << format("0x%04" PRIx64, Abbreviations->getOffset()); + } + OS << " addr_size = " << format("0x%02x", getAddressByteSize()); if (getVersion() >= 5 && getUnitType() != dwarf::DW_UT_compile) OS << " DWO_id = " << format("0x%016" PRIx64, *getDWOId()); OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset()) diff --git a/third_party/llvm-project/DWARFContext.cpp b/third_party/llvm-project/DWARFContext.cpp index da865a2c3..64c153bfa 100644 --- a/third_party/llvm-project/DWARFContext.cpp +++ b/third_party/llvm-project/DWARFContext.cpp @@ -1507,7 +1507,9 @@ class DWARFObjInMemory final : public DWARFObject { public: DWARFObjInMemory(const StringMap<std::unique_ptr<MemoryBuffer>> &Sections, uint8_t AddrSize, bool IsLittleEndian) - : IsLittleEndian(IsLittleEndian) { + : IsLittleEndian(IsLittleEndian), + AddressSize(4) // XXX BINARYEN + { for (const auto &SecIt : Sections) { if (StringRef *SectionData = mapSectionToMember(SecIt.first())) *SectionData = SecIt.second->getBuffer(); diff --git a/third_party/llvm-project/DWARFDebugInfoEntry.cpp b/third_party/llvm-project/DWARFDebugInfoEntry.cpp index 87eab34d5..2da854fe2 100644 --- a/third_party/llvm-project/DWARFDebugInfoEntry.cpp +++ b/third_party/llvm-project/DWARFDebugInfoEntry.cpp @@ -38,7 +38,11 @@ bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, AbbrevDecl = nullptr; return true; } - AbbrevDecl = U.getAbbreviations()->getAbbreviationDeclaration(AbbrCode); + if (auto* Abbreviations = U.getAbbreviations()) { // XXX BINARYEN + AbbrevDecl = Abbreviations->getAbbreviationDeclaration(AbbrCode); + } else { + AbbrevDecl = nullptr; // XXX BINARYEN + } if (nullptr == AbbrevDecl) { // Restore the original offset. *OffsetPtr = Offset; diff --git a/third_party/llvm-project/DWARFEmitter.cpp b/third_party/llvm-project/DWARFEmitter.cpp index dbaa06111..79f988498 100644 --- a/third_party/llvm-project/DWARFEmitter.cpp +++ b/third_party/llvm-project/DWARFEmitter.cpp @@ -221,9 +221,15 @@ static void EmitFileEntry(raw_ostream &OS, const DWARFYAML::File &File) { encodeULEB128(File.Length, OS); } -void DWARFYAML::EmitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) { +void DWARFYAML::EmitDebugLine(raw_ostream &RealOS, const DWARFYAML::Data &DI) { for (const auto &LineTable : DI.DebugLines) { - writeInitialLength(LineTable.Length, OS, DI.IsLittleEndian); + // XXX BINARYEN We need to update each line table's length. Write to a + // temp stream first, then get the size from that. + std::string Buffer; + raw_string_ostream OS(Buffer); + + // XXX BINARYEN writeInitialLength(LineTable.Length, OS, DI.IsLittleEndian); + uint64_t SizeOfPrologueLength = LineTable.Length.isDWARF64() ? 8 : 4; writeInteger((uint16_t)LineTable.Version, OS, DI.IsLittleEndian); writeVariableSizedInteger(LineTable.PrologueLength, SizeOfPrologueLength, @@ -301,6 +307,14 @@ void DWARFYAML::EmitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) { } } } + // XXX BINARYEN Write to the actual stream, with the proper size. + // We assume for now that the length fits in 32 bits. + size_t Size = OS.str().size(); + if (Size >= UINT32_MAX) { + llvm_unreachable("Table is too big"); + } + writeInteger((uint32_t)Size, RealOS, DI.IsLittleEndian); + RealOS << OS.str(); } } diff --git a/third_party/llvm-project/DWARFVisitor.cpp b/third_party/llvm-project/DWARFVisitor.cpp index ecb5967ac..35d5ccf57 100644 --- a/third_party/llvm-project/DWARFVisitor.cpp +++ b/third_party/llvm-project/DWARFVisitor.cpp @@ -46,6 +46,9 @@ static unsigned getRefSize(const DWARFYAML::Unit &Unit) { template <typename T> void DWARFYAML::VisitorImpl<T>::traverseDebugInfo() { for (auto &Unit : DebugInfo.CompileUnits) { onStartCompileUnit(Unit); + if (Unit.Entries.empty()) { // XXX BINARYEN + continue; + } auto FirstAbbrevCode = Unit.Entries[0].AbbrCode; for (auto &Entry : Unit.Entries) { diff --git a/third_party/llvm-project/dwarf2yaml.cpp b/third_party/llvm-project/dwarf2yaml.cpp index bdaf1e429..7d5f2e048 100644 --- a/third_party/llvm-project/dwarf2yaml.cpp +++ b/third_party/llvm-project/dwarf2yaml.cpp @@ -146,7 +146,9 @@ void dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) { NewUnit.Version = CU->getVersion(); if(NewUnit.Version >= 5) NewUnit.Type = (dwarf::UnitType)CU->getUnitType(); - NewUnit.AbbrOffset = CU->getAbbreviations()->getOffset(); + if (auto* Abbreviations = CU->getAbbreviations()) { // XXX BINARYEN + NewUnit.AbbrOffset = Abbreviations->getOffset(); + } NewUnit.AddrSize = CU->getAddressByteSize(); for (auto DIE : CU->dies()) { DWARFYAML::Entry NewEntry; |