aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-06-14 05:31:00 +0000
committerZachary Turner <zturner@google.com>2017-06-14 05:31:00 +0000
commita3da4467fa8ed514130736c6c15f01422159d00d (patch)
tree12356bbf4e58c9d059fb2899b240256e75d75a81 /llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
parentf4ea23d3a58ee23d13b719e525e0575a29e510da (diff)
downloadllvm-a3da4467fa8ed514130736c6c15f01422159d00d.zip
llvm-a3da4467fa8ed514130736c6c15f01422159d00d.tar.gz
llvm-a3da4467fa8ed514130736c6c15f01422159d00d.tar.bz2
[codeview] Make obj2yaml/yaml2obj support .debug$S/T sections.
This allows us to use yaml2obj and obj2yaml to round-trip CodeView symbol and type information without having to manually specify the bytes of the section. This makes for much easier to maintain tests. See the tests under lld/COFF in this patch for example. Before they just said SectionData: <blob> whereas now we can use meaningful record descriptions. Note that it still supports the SectionData yaml field, which could be useful for initializing a section to invalid bytes for testing, for example. Differential Revision: https://reviews.llvm.org/D34127 llvm-svn: 305366
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp')
-rw-r--r--llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
index 6e647c4..de02525 100644
--- a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
+++ b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
@@ -58,6 +58,10 @@ Error DebugStringTableSubsection::commit(BinaryStreamWriter &Writer) const {
uint32_t Begin = Writer.getOffset();
uint32_t End = Begin + StringSize;
+ // Write a null string at the beginning.
+ if (auto EC = Writer.writeCString(StringRef()))
+ return EC;
+
for (auto &Pair : Strings) {
StringRef S = Pair.getKey();
uint32_t Offset = Begin + Pair.getValue();
@@ -68,6 +72,7 @@ Error DebugStringTableSubsection::commit(BinaryStreamWriter &Writer) const {
}
Writer.setOffset(End);
+ assert((End - Begin) == StringSize);
return Error::success();
}