summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-10-07 08:04:37 -0700
committerGitHub <noreply@github.com>2022-10-07 08:04:37 -0700
commitd5aa6e7c070a7a14a6eb23edbe6343f6ee638e92 (patch)
tree123273782f77363c8f927a6458cb45a2123ab050
parent7fc26f3e78f72ecaa5b79ebe042b95a0be422327 (diff)
downloadbinaryen-d5aa6e7c070a7a14a6eb23edbe6343f6ee638e92.tar.gz
binaryen-d5aa6e7c070a7a14a6eb23edbe6343f6ee638e92.tar.bz2
binaryen-d5aa6e7c070a7a14a6eb23edbe6343f6ee638e92.zip
[DWARF] Warn on unsupport DWARF versions and content (#5120)
Unfortunately there isn't a single place where an error may occur. I tested on several files with different flags and added sufficient warnings so that we warn on them all.
-rw-r--r--src/wasm/wasm-debug.cpp13
-rw-r--r--third_party/llvm-project/DWARFEmitter.cpp3
-rw-r--r--third_party/llvm-project/include/llvm/include/llvm/DebugInfo/DWARFContext.h3
3 files changed, 14 insertions, 5 deletions
diff --git a/src/wasm/wasm-debug.cpp b/src/wasm/wasm-debug.cpp
index 8de691272..3e0749f36 100644
--- a/src/wasm/wasm-debug.cpp
+++ b/src/wasm/wasm-debug.cpp
@@ -64,6 +64,10 @@ struct BinaryenDWARFInfo {
uint8_t addrSize = AddressSize;
bool isLittleEndian = true;
context = llvm::DWARFContext::create(sections, addrSize, isLittleEndian);
+ if (context->getMaxVersion() > 4) {
+ std::cerr << "warning: unsupported DWARF version ("
+ << context->getMaxVersion() << ")\n";
+ }
}
};
@@ -162,8 +166,8 @@ struct LineState {
}
default: {
// An unknown opcode, ignore.
- std::cerr << "warning: unknown subopcopde " << opcode.SubOpcode
- << '\n';
+ std::cerr << "warning: unknown subopcode " << opcode.SubOpcode
+ << " (this may be an unsupported version of DWARF)\n";
}
}
break;
@@ -180,7 +184,10 @@ struct LineState {
return true;
}
case llvm::dwarf::DW_LNS_advance_pc: {
- assert(table.MinInstLength == 1);
+ if (table.MinInstLength != 1) {
+ std::cerr << "warning: bad MinInstLength "
+ "(this may be an unsupported DWARF version)";
+ }
addr += opcode.Data;
break;
}
diff --git a/third_party/llvm-project/DWARFEmitter.cpp b/third_party/llvm-project/DWARFEmitter.cpp
index 1dc59ed53..7c66a82fa 100644
--- a/third_party/llvm-project/DWARFEmitter.cpp
+++ b/third_party/llvm-project/DWARFEmitter.cpp
@@ -197,7 +197,8 @@ protected:
void onEndCompileUnit(const DWARFYAML::Unit &CU) {
size_t EndPos = OS.tell();
if (EndPos - StartPos != CU.Length.getLength() && !CU.AddrSizeChanged) {
- llvm_unreachable("compile unit size was incorrect");
+ llvm_unreachable("compile unit size was incorrect "
+ "(this may be an unsupported version of DWARF)");
}
}
diff --git a/third_party/llvm-project/include/llvm/include/llvm/DebugInfo/DWARFContext.h b/third_party/llvm-project/include/llvm/include/llvm/DebugInfo/DWARFContext.h
index 2dec107d1..510cf4083 100644
--- a/third_party/llvm-project/include/llvm/include/llvm/DebugInfo/DWARFContext.h
+++ b/third_party/llvm-project/include/llvm/include/llvm/DebugInfo/DWARFContext.h
@@ -332,7 +332,8 @@ public:
bool isLittleEndian() const { return DObj->isLittleEndian(); }
static bool isSupportedVersion(unsigned version) {
- return version == 2 || version == 3 || version == 4 || version == 5;
+ // XXX BINARYEN: removed version 5, which we do not support
+ return version == 2 || version == 3 || version == 4;
}
std::shared_ptr<DWARFContext> getDWOContext(StringRef AbsolutePath);