summaryrefslogtreecommitdiff
path: root/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:06 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:06 +0000
commit7ab83427af0f77b59941ceba41d509d7d097b065 (patch)
treecc41c05b1db454e3d802f34df75e636ee922ad87 /lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
parentd288ef4c1788d3a951a7558c68312c2d320612b1 (diff)
Notes
Diffstat (limited to 'lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp')
-rw-r--r--lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp b/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
index 2e72242181b0a..6e647c4b976b5 100644
--- a/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
+++ b/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
@@ -23,6 +23,9 @@ Error DebugStringTableSubsectionRef::initialize(BinaryStreamRef Contents) {
Stream = Contents;
return Error::success();
}
+Error DebugStringTableSubsectionRef::initialize(BinaryStreamReader &Reader) {
+ return Reader.readStreamRef(Stream);
+}
Expected<StringRef>
DebugStringTableSubsectionRef::getString(uint32_t Offset) const {
@@ -52,20 +55,19 @@ uint32_t DebugStringTableSubsection::calculateSerializedSize() const {
}
Error DebugStringTableSubsection::commit(BinaryStreamWriter &Writer) const {
- assert(Writer.bytesRemaining() == StringSize);
- uint32_t MaxOffset = 1;
+ uint32_t Begin = Writer.getOffset();
+ uint32_t End = Begin + StringSize;
for (auto &Pair : Strings) {
StringRef S = Pair.getKey();
- uint32_t Offset = Pair.getValue();
+ uint32_t Offset = Begin + Pair.getValue();
Writer.setOffset(Offset);
if (auto EC = Writer.writeCString(S))
return EC;
- MaxOffset = std::max<uint32_t>(MaxOffset, Offset + S.size() + 1);
+ assert(Writer.getOffset() <= End);
}
- Writer.setOffset(MaxOffset);
- assert(Writer.bytesRemaining() == 0);
+ Writer.setOffset(End);
return Error::success();
}