summaryrefslogtreecommitdiff
path: root/third_party/llvm-project/DWARFEmitter.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-01-27 14:24:08 -0800
committerGitHub <noreply@github.com>2020-01-27 14:24:08 -0800
commit79fdd327c239597207e8313c6bf83a846917ebc2 (patch)
treed909e9d09bfd3071ba107c676f2254469552231c /third_party/llvm-project/DWARFEmitter.cpp
parentde18d960d51810d71b5f2fa812c21a991924f00c (diff)
downloadbinaryen-79fdd327c239597207e8313c6bf83a846917ebc2.tar.gz
binaryen-79fdd327c239597207e8313c6bf83a846917ebc2.tar.bz2
binaryen-79fdd327c239597207e8313c6bf83a846917ebc2.zip
DWARF: Fix emitting of DW_FORM_sdata (#2627)
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);