diff --git a/lld/test/wasm/section-symbol-relocs.yaml b/lld/test/wasm/section-symbol-relocs.yaml --- a/lld/test/wasm/section-symbol-relocs.yaml +++ b/lld/test/wasm/section-symbol-relocs.yaml @@ -49,3 +49,13 @@ # 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 diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -234,6 +234,8 @@ } void Writer::createTypeSection() { + if (!Types.size()) + return; SyntheticSection *Section = createSyntheticSection(WASM_SEC_TYPE); raw_ostream &OS = Section->getStream(); writeUleb128(OS, Types.size(), "type count");