diff options
author | David Blaikie <dblaikie@gmail.com> | 2016-04-05 20:26:50 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2016-04-05 20:26:50 +0000 |
commit | 62be5ae5779c9e7acd8c8e17a89694d7fadaed2f (patch) | |
tree | f4fe5c02e108d1121bf0c9ed7b3a4bc034b17c23 /llvm/tools/llvm-dwp/llvm-dwp.cpp | |
parent | ea7df770aed047bf7959a18fa6422d4d5631ef23 (diff) | |
download | bcm5719-llvm-62be5ae5779c9e7acd8c8e17a89694d7fadaed2f.tar.gz bcm5719-llvm-62be5ae5779c9e7acd8c8e17a89694d7fadaed2f.zip |
llvm-dwp: Handle GCC's use of multiple debug_types.dwo sections in a single .dwo file
(also includes the .test file missing from my previous commit, r265452)
llvm-svn: 265457
Diffstat (limited to 'llvm/tools/llvm-dwp/llvm-dwp.cpp')
-rw-r--r-- | llvm/tools/llvm-dwp/llvm-dwp.cpp | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index f9dada2075b..bd836102a74 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -231,36 +231,36 @@ static void addAllTypesFromDWP( static void addAllTypes(MCStreamer &Out, MapVector<uint64_t, UnitIndexEntry> &TypeIndexEntries, - MCSection *OutputTypes, StringRef Types, + MCSection *OutputTypes, + const std::vector<StringRef> &TypesSections, const UnitIndexEntry &CUEntry, uint32_t &TypesOffset) { - if (Types.empty()) - return; - - Out.SwitchSection(OutputTypes); - uint32_t Offset = 0; - DataExtractor Data(Types, true, 0); - while (Data.isValidOffset(Offset)) { - UnitIndexEntry Entry = CUEntry; - // Zero out the debug_info contribution - Entry.Contributions[0] = {}; - auto &C = Entry.Contributions[DW_SECT_TYPES - DW_SECT_INFO]; - C.Offset = TypesOffset; - auto PrevOffset = Offset; - // Length of the unit, including the 4 byte length field. - C.Length = Data.getU32(&Offset) + 4; - - Data.getU16(&Offset); // Version - Data.getU32(&Offset); // Abbrev offset - Data.getU8(&Offset); // Address size - auto Signature = Data.getU64(&Offset); - Offset = PrevOffset + C.Length; - - auto P = TypeIndexEntries.insert(std::make_pair(Signature, Entry)); - if (!P.second) - continue; + for (StringRef Types : TypesSections) { + Out.SwitchSection(OutputTypes); + uint32_t Offset = 0; + DataExtractor Data(Types, true, 0); + while (Data.isValidOffset(Offset)) { + UnitIndexEntry Entry = CUEntry; + // Zero out the debug_info contribution + Entry.Contributions[0] = {}; + auto &C = Entry.Contributions[DW_SECT_TYPES - DW_SECT_INFO]; + C.Offset = TypesOffset; + auto PrevOffset = Offset; + // Length of the unit, including the 4 byte length field. + C.Length = Data.getU32(&Offset) + 4; + + Data.getU16(&Offset); // Version + Data.getU32(&Offset); // Abbrev offset + Data.getU8(&Offset); // Address size + auto Signature = Data.getU64(&Offset); + Offset = PrevOffset + C.Length; + + auto P = TypeIndexEntries.insert(std::make_pair(Signature, Entry)); + if (!P.second) + continue; - Out.EmitBytes(Types.substr(PrevOffset, C.Length)); - TypesOffset += C.Length; + Out.EmitBytes(Types.substr(PrevOffset, C.Length)); + TypesOffset += C.Length; + } } } @@ -399,7 +399,7 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) { StringRef CurStrSection; StringRef CurStrOffsetSection; - StringRef CurTypesSection; + std::vector<StringRef> CurTypesSection; StringRef InfoSection; StringRef AbbrevSection; StringRef CurCUIndexSection; @@ -468,7 +468,7 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) { else if (OutSection == StrSection) CurStrSection = Contents; else if (OutSection == TypesSection) - CurTypesSection = Contents; + CurTypesSection.push_back(Contents); else if (OutSection == CUIndexSection) CurCUIndexSection = Contents; else if (OutSection == TUIndexSection) @@ -517,6 +517,7 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) { } if (!CurTypesSection.empty()) { + assert(CurTypesSection.size() == 1); if (CurTUIndexSection.empty()) return make_error_code(std::errc::invalid_argument); DWARFUnitIndex TUIndex(DW_SECT_TYPES); @@ -525,7 +526,7 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) { if (!TUIndex.parse(TUIndexData)) return make_error_code(std::errc::invalid_argument); addAllTypesFromDWP(Out, TypeIndexEntries, TUIndex, TypesSection, - CurTypesSection, CurEntry, + CurTypesSection.front(), CurEntry, ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO]); } } else { |