[WebAssembly] Don't generate empty type sections.

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

llvm-svn: 360940
This commit is contained in:
Sam Clegg 2019-05-16 21:22:43 +00:00
parent 9adabefdce
commit 1a53ff2a13
2 changed files with 12 additions and 0 deletions

View 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

View 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");