diff options
Diffstat (limited to 'third_party/llvm-project')
-rw-r--r-- | third_party/llvm-project/DWARFEmitter.cpp | 13 | ||||
-rw-r--r-- | third_party/llvm-project/dwarf2yaml.cpp | 7 |
2 files changed, 19 insertions, 1 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); diff --git a/third_party/llvm-project/dwarf2yaml.cpp b/third_party/llvm-project/dwarf2yaml.cpp index 994be5511..b43b0e420 100644 --- a/third_party/llvm-project/dwarf2yaml.cpp +++ b/third_party/llvm-project/dwarf2yaml.cpp @@ -235,13 +235,18 @@ void dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) { case dwarf::DW_FORM_data2: case dwarf::DW_FORM_data4: case dwarf::DW_FORM_data8: - case dwarf::DW_FORM_sdata: case dwarf::DW_FORM_udata: case dwarf::DW_FORM_ref_sup4: case dwarf::DW_FORM_ref_sup8: if (auto Val = FormValue.getValue().getAsUnsignedConstant()) NewValue.Value = Val.getValue(); break; + // XXX BINARYEN: sdata is signed, and FormValue won't return it as + // unsigned (it returns an empty value). + case dwarf::DW_FORM_sdata: + if (auto Val = FormValue.getValue().getAsSignedConstant()) + NewValue.Value = Val.getValue(); + break; case dwarf::DW_FORM_string: if (auto Val = FormValue.getValue().getAsCString()) NewValue.CStr = Val.getValue(); |