[WebAssembly] Don't generate empty type sections.
authorSam Clegg <sbc@chromium.org>
Thu, 16 May 2019 21:22:43 +0000 (21:22 +0000)
committerSam Clegg <sbc@chromium.org>
Thu, 16 May 2019 21:22:43 +0000 (21:22 +0000)
Differential Revision: https://reviews.llvm.org/D61991

llvm-svn: 360940

lld/test/wasm/section-symbol-relocs.yaml
lld/wasm/Writer.cpp

index ad292e39f99e54c6a4f7566918fbb05ab16bac73..b7d8a442536d8b08b51c6d8b8ca2c02f2c80d292 100644 (file)
@@ -49,3 +49,13 @@ Sections:
 # RELOC-NEXT:         Offset:          0x0000000B
 # RELOC-NEXT:         Addend:          3
 # RELOC-NEXT:    Name:            green
+#
+# RELOC:        SymbolTable:
+# RELOC-NEXT:     - Index:           0
+# RELOC-NEXT:       Kind:            SECTION
+# RELOC-NEXT:       Flags:           [ BINDING_LOCAL ]
+# RELOC-NEXT:       Section:         2
+# RELOC-NEXT:     - Index:           1
+# RELOC-NEXT:       Kind:            SECTION
+# RELOC-NEXT:       Flags:           [ BINDING_LOCAL ]
+# RELOC-NEXT:       Section:         3
index fedaa54ce19173f5593833dd6041947b8fa4178b..8460f8575c8a2c5f7a8f9652d62a11a8a15f9e25 100644 (file)
@@ -234,6 +234,8 @@ void Writer::createImportSection() {
 }
 
 void Writer::createTypeSection() {
+  if (!Types.size())
+    return;
   SyntheticSection *Section = createSyntheticSection(WASM_SEC_TYPE);
   raw_ostream &OS = Section->getStream();
   writeUleb128(OS, Types.size(), "type count");