OSDN Git Service

[WebAssembly] Ensure all .debug_XXX section has proper symbol names
authorSam Clegg <sbc@chromium.org>
Mon, 7 May 2018 19:40:50 +0000 (19:40 +0000)
committerSam Clegg <sbc@chromium.org>
Mon, 7 May 2018 19:40:50 +0000 (19:40 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331664 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCObjectFileInfo.cpp
lib/MC/WasmObjectWriter.cpp

index ce9c352..e289017 100644 (file)
@@ -870,10 +870,13 @@ void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
   DwarfLineStrSection =
       Ctx->getWasmSection(".debug_line_str", SectionKind::getMetadata());
   DwarfStrSection = Ctx->getWasmSection(".debug_str", SectionKind::getMetadata(), ".debug_str");
-  DwarfLocSection = Ctx->getWasmSection(".debug_loc", SectionKind::getMetadata());
-  DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", SectionKind::getMetadata(), ".section_abbrev");
+  DwarfLocSection = Ctx->getWasmSection(
+      ".debug_loc", SectionKind::getMetadata(), ".debug_loc");
+  DwarfAbbrevSection = Ctx->getWasmSection(
+      ".debug_abbrev", SectionKind::getMetadata(), ".debug_abbrev");
   DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", SectionKind::getMetadata());
-  DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", SectionKind::getMetadata(), ".debug_range");
+  DwarfRangesSection = Ctx->getWasmSection(
+      ".debug_ranges", SectionKind::getMetadata(), ".debug_ranges");
   DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", SectionKind::getMetadata(), ".debug_macinfo");
   DwarfAddrSection = Ctx->getWasmSection(".debug_addr", SectionKind::getMetadata());
   DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata());
index 407907c..5ac5f6c 100644 (file)
@@ -1207,8 +1207,12 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
         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);
     }
   }