summaryrefslogtreecommitdiff
path: root/third_party/llvm-project/DWARFEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/llvm-project/DWARFEmitter.cpp')
-rw-r--r--third_party/llvm-project/DWARFEmitter.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/third_party/llvm-project/DWARFEmitter.cpp b/third_party/llvm-project/DWARFEmitter.cpp
index 8acef5bef..b155fb807 100644
--- a/third_party/llvm-project/DWARFEmitter.cpp
+++ b/third_party/llvm-project/DWARFEmitter.cpp
@@ -170,9 +170,12 @@ namespace {
class DumpVisitor : public DWARFYAML::ConstVisitor {
raw_ostream &OS;
+ size_t StartPos; // XXX BINARYEN
+
protected:
void onStartCompileUnit(const DWARFYAML::Unit &CU) override {
writeInitialLength(CU.Length, OS, DebugInfo.IsLittleEndian);
+ StartPos = OS.tell(); // XXX BINARYEN
writeInteger((uint16_t)CU.Version, OS, DebugInfo.IsLittleEndian);
if(CU.Version >= 5) {
writeInteger((uint8_t)CU.Type, OS, DebugInfo.IsLittleEndian);
@@ -184,6 +187,16 @@ protected:
}
}
+ // XXX BINARYEN Make sure we emit the right size. We should not change the
+ // size as we only modify relocatable fields like addresses, and such fields
+ // have a fixed size, so any change is a bug.
+ void onEndCompileUnit(const DWARFYAML::Unit &CU) {
+ size_t EndPos = OS.tell();
+ if (EndPos - StartPos != CU.Length.getLength()) {
+ llvm_unreachable("compile unit size was incorrect");
+ }
+ }
+
void onStartDIE(const DWARFYAML::Unit &CU,
const DWARFYAML::Entry &DIE) override {
encodeULEB128(DIE.AbbrCode, OS);