[WebAssembly] Ensure all .debug_XXX section has proper symbol names
Updated wasm section symbols names to match section name, and ensure all
referenced sections will have a symbol (per DWARF spec v3, Figure 43)
Patch by Yury Delendik!
Differential Revision: https://reviews.llvm.org/D46543
llvm-svn: 331664
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 407907c..5ac5f6c 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1207,8 +1207,12 @@
Name = Name.substr(strlen(".custom_section."));
MCSymbol* Begin = Sec.getBeginSymbol();
- if (Begin)
+ if (Begin) {
WasmIndices[cast<MCSymbolWasm>(Begin)] = CustomSections.size();
+ if (Name != Begin->getName())
+ report_fatal_error("section name and begin symbol should match: " +
+ Twine(Name));
+ }
CustomSections.emplace_back(Name, &Section);
}
}