diff options
Diffstat (limited to 'llvm/tools/llvm-readobj/COFFDumper.cpp')
-rw-r--r-- | llvm/tools/llvm-readobj/COFFDumper.cpp | 64 |
1 files changed, 29 insertions, 35 deletions
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp index f0699cecfbd..d76822482ee 100644 --- a/llvm/tools/llvm-readobj/COFFDumper.cpp +++ b/llvm/tools/llvm-readobj/COFFDumper.cpp @@ -988,7 +988,6 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, SmallVector<StringRef, 10> FunctionNames; StringMap<StringRef> FunctionLineTables; - std::map<StringRef, const FrameData *> FunctionFrameData; ListScope D(W, "CodeViewDebugInfo"); // Print the section to allow correlation with printSections. @@ -1028,7 +1027,8 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, // Optionally print the subsection bytes in case our parsing gets confused // later. if (opts::CodeViewSubsectionBytes) - W.printBinaryBlock("SubSectionContents", Contents); + printBinaryBlockWithRelocs("SubSectionContents", Section, SectionContents, + Contents); switch (ModuleSubstreamKind(SubType)) { case ModuleSubstreamKind::Symbols: @@ -1070,23 +1070,30 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, break; } case ModuleSubstreamKind::FrameData: { - const size_t RelocationSize = 4; - if (SubSectionSize != sizeof(FrameData) + RelocationSize) { - // There should be exactly one relocation followed by the FrameData - // contents. - error(object_error::parse_failed); - return; - } - - const auto *FD = reinterpret_cast<const FrameData *>( - Contents.drop_front(RelocationSize).data()); - + // First four bytes is a relocation against the function. + const uint32_t *CodePtr; + error(consumeObject(Contents, CodePtr)); StringRef LinkageName; - error(resolveSymbolName(Obj->getCOFFSection(Section), SectionOffset, - LinkageName)); - if (!FunctionFrameData.insert(std::make_pair(LinkageName, FD)).second) { - error(object_error::parse_failed); - return; + error(resolveSymbolName(Obj->getCOFFSection(Section), SectionContents, + CodePtr, LinkageName)); + W.printString("LinkageName", LinkageName); + + // To find the active frame description, search this array for the + // smallest PC range that includes the current PC. + while (!Contents.empty()) { + const FrameData *FD; + error(consumeObject(Contents, FD)); + DictScope S(W, "FrameData"); + W.printHex("RvaStart", FD->RvaStart); + W.printHex("CodeSize", FD->CodeSize); + W.printHex("LocalSize", FD->LocalSize); + W.printHex("ParamsSize", FD->ParamsSize); + W.printHex("MaxStackSize", FD->MaxStackSize); + W.printString("FrameFunc", + CVStringTable.drop_front(FD->FrameFunc).split('\0').first); + W.printHex("PrologSize", FD->PrologSize); + W.printHex("SavedRegsSize", FD->SavedRegsSize); + W.printFlags("Flags", FD->Flags, makeArrayRef(FrameDataFlags)); } break; } @@ -1095,6 +1102,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, default: break; } + W.flush(); } // Dump the line tables now that we've read all the subsections and know all @@ -1168,22 +1176,6 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, } } } - - for (auto FrameDataPair : FunctionFrameData) { - StringRef LinkageName = FrameDataPair.first; - const FrameData *FD = FrameDataPair.second; - ListScope S(W, "FunctionFrameData"); - W.printString("LinkageName", LinkageName); - W.printHex("RvaStart", FD->RvaStart); - W.printHex("CodeSize", FD->CodeSize); - W.printHex("LocalSize", FD->LocalSize); - W.printHex("ParamsSize", FD->ParamsSize); - W.printHex("MaxStackSize", FD->MaxStackSize); - W.printString("FrameFunc", StringRef(CVStringTable.data() + FD->FrameFunc)); - W.printHex("PrologSize", FD->PrologSize); - W.printHex("SavedRegsSize", FD->SavedRegsSize); - W.printFlags("Flags", FD->Flags, makeArrayRef(FrameDataFlags)); - } } static std::error_code decodeNumerictLeaf(StringRef &Data, APSInt &Num) { @@ -1435,7 +1427,7 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection, W.printNumber("ChangeCodeLength", GetCompressedAnnotation()); break; case ChangeFile: - W.printHex("ChangeFile", GetCompressedAnnotation()); + printFileNameForOffset("ChangeFile", GetCompressedAnnotation()); break; case ChangeLineOffset: W.printNumber("ChangeLineOffset", @@ -1711,7 +1703,9 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection, if (opts::CodeViewSubsectionBytes) printBinaryBlockWithRelocs("SymData", Section, SectionContents, OrigSymData); + W.flush(); } + W.flush(); } void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) { |