diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-20 11:41:25 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-20 11:41:25 +0000 |
commit | d9484dd61cc151c4f34c31e07f693fefa66316b5 (patch) | |
tree | ab0560b3da293f1fafd3269c59692e929418f5c2 /contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp | |
parent | 79e0962d4c3cf1f0acf359a9d69cb3ac68c414c4 (diff) | |
parent | d8e91e46262bc44006913e6796843909f1ac7bcd (diff) |
Notes
Diffstat (limited to 'contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp')
-rw-r--r-- | contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp index fd558aa9cc8a..5881bf177a55 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp @@ -14,8 +14,11 @@ using namespace llvm; using namespace llvm::codeview; Error DebugFrameDataSubsectionRef::initialize(BinaryStreamReader Reader) { - if (auto EC = Reader.readObject(RelocPtr)) - return EC; + if (Reader.bytesRemaining() % sizeof(FrameData) != 0) { + if (auto EC = Reader.readObject(RelocPtr)) + return EC; + } + if (Reader.bytesRemaining() % sizeof(FrameData) != 0) return make_error<CodeViewError>(cv_error_code::corrupt_record, "Invalid frame data record format!"); @@ -26,15 +29,30 @@ Error DebugFrameDataSubsectionRef::initialize(BinaryStreamReader Reader) { return Error::success(); } +Error DebugFrameDataSubsectionRef::initialize(BinaryStreamRef Section) { + BinaryStreamReader Reader(Section); + return initialize(Reader); +} + uint32_t DebugFrameDataSubsection::calculateSerializedSize() const { - return 4 + sizeof(FrameData) * Frames.size(); + uint32_t Size = sizeof(FrameData) * Frames.size(); + if (IncludeRelocPtr) + Size += sizeof(uint32_t); + return Size; } Error DebugFrameDataSubsection::commit(BinaryStreamWriter &Writer) const { - if (auto EC = Writer.writeInteger<uint32_t>(0)) - return EC; - - if (auto EC = Writer.writeArray(makeArrayRef(Frames))) + if (IncludeRelocPtr) { + if (auto EC = Writer.writeInteger<uint32_t>(0)) + return EC; + } + + std::vector<FrameData> SortedFrames(Frames.begin(), Frames.end()); + std::sort(SortedFrames.begin(), SortedFrames.end(), + [](const FrameData &LHS, const FrameData &RHS) { + return LHS.RvaStart < RHS.RvaStart; + }); + if (auto EC = Writer.writeArray(makeArrayRef(SortedFrames))) return EC; return Error::success(); } |