[lld] r360940 - [WebAssembly] Don't generate empty type sections.

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 14:22:43 PDT 2019


Author: sbc
Date: Thu May 16 14:22:43 2019
New Revision: 360940

URL: http://llvm.org/viewvc/llvm-project?rev=360940&view=rev
Log:
[WebAssembly] Don't generate empty type sections.

Differential Revision: https://reviews.llvm.org/D61991

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

Modified: lld/trunk/test/wasm/section-symbol-relocs.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/section-symbol-relocs.yaml?rev=360940&r1=360939&r2=360940&view=diff
==============================================================================
--- lld/trunk/test/wasm/section-symbol-relocs.yaml (original)
+++ lld/trunk/test/wasm/section-symbol-relocs.yaml Thu May 16 14:22:43 2019
@@ -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

Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=360940&r1=360939&r2=360940&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Thu May 16 14:22:43 2019
@@ -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");




More information about the llvm-commits mailing list