diff options
-rw-r--r-- | llvm/test/tools/llvm-readobj/codeview-linetables.test | 14 | ||||
-rw-r--r-- | llvm/tools/llvm-readobj/COFFDumper.cpp | 64 |
2 files changed, 36 insertions, 42 deletions
diff --git a/llvm/test/tools/llvm-readobj/codeview-linetables.test b/llvm/test/tools/llvm-readobj/codeview-linetables.test index 4867a62c6b4..fe68e7efdb0 100644 --- a/llvm/test/tools/llvm-readobj/codeview-linetables.test +++ b/llvm/test/tools/llvm-readobj/codeview-linetables.test @@ -34,11 +34,11 @@ MFUN32-NEXT: Subsection [ MFUN32-NEXT: SubSectionType: Symbols (0xF1) MFUN32-NEXT: SubSectionSize: 0x52 MFUN32: ] -MFUN32: Subsection [ +MFUN32: Subsection [ MFUN32-NEXT: SubSectionType: FrameData (0xF5) MFUN32-NEXT: SubSectionSize: 0x24 MFUN32: ] -MFUN32-NEXT: Subsection [ +MFUN32: Subsection [ MFUN32-NEXT: SubSectionType: Symbols (0xF1) MFUN32-NEXT: SubSectionSize: 0x4B MFUN32: ProcStart { @@ -48,7 +48,7 @@ MFUN32: LinkageName: _x MFUN32: } MFUN32: ProcEnd MFUN32: ] -MFUN32-NEXT: Subsection [ +MFUN32: Subsection [ MFUN32-NEXT: SubSectionType: Lines (0xF2) MFUN32-NEXT: SubSectionSize: 0x30 MFUN32: LinkageName: _x @@ -57,7 +57,7 @@ MFUN32-NEXT: Subsection [ MFUN32-NEXT: SubSectionType: FrameData (0xF5) MFUN32-NEXT: SubSectionSize: 0x24 MFUN32: ] -MFUN32-NEXT: Subsection [ +MFUN32: Subsection [ MFUN32-NEXT: SubSectionType: Symbols (0xF1) MFUN32-NEXT: SubSectionSize: 0x4B MFUN32: ProcStart { @@ -76,7 +76,7 @@ MFUN32-NEXT: Subsection [ MFUN32-NEXT: SubSectionType: FrameData (0xF5) MFUN32-NEXT: SubSectionSize: 0x24 MFUN32: ] -MFUN32-NEXT: Subsection [ +MFUN32: Subsection [ MFUN32-NEXT: SubSectionType: Symbols (0xF1) MFUN32-NEXT: SubSectionSize: 0x4B MFUN32: ProcStart { @@ -86,7 +86,7 @@ MFUN32: LinkageName: _f MFUN32: } MFUN32: ProcEnd MFUN32: ] -MFUN32-NEXT: Subsection [ +MFUN32: Subsection [ MFUN32-NEXT: SubSectionType: Lines (0xF2) MFUN32-NEXT: SubSectionSize: 0x40 MFUN32: LinkageName: _f @@ -362,7 +362,7 @@ MFILE32: Subsection [ MFILE32-NEXT: SubSectionType: FrameData (0xF5) MFILE32-NEXT: SubSectionSize: 0x24 MFILE32: ] -MFILE32-NEXT: Subsection [ +MFILE32: Subsection [ MFILE32-NEXT: SubSectionType: Symbols (0xF1) MFILE32-NEXT: SubSectionSize: 0x4B MFILE32: ProcStart { 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) { |