diff options
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 63677095918..2994772c519 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -326,6 +326,7 @@ private: void writeFunctionSection(ArrayRef<WasmFunction> Functions); void writeExportSection(ArrayRef<wasm::WasmExport> Exports); void writeElemSection(ArrayRef<uint32_t> TableElems); + void writeDataCountSection(); void writeCodeSection(const MCAssembler &Asm, const MCAsmLayout &Layout, ArrayRef<WasmFunction> Functions); void writeDataSection(); @@ -849,6 +850,16 @@ void WasmObjectWriter::writeElemSection(ArrayRef<uint32_t> TableElems) { endSection(Section); } +void WasmObjectWriter::writeDataCountSection() { + if (DataSegments.empty()) + return; + + SectionBookkeeping Section; + startSection(Section, wasm::WASM_SEC_DATACOUNT); + encodeULEB128(DataSegments.size(), W.OS); + endSection(Section); +} + void WasmObjectWriter::writeCodeSection(const MCAssembler &Asm, const MCAsmLayout &Layout, ArrayRef<WasmFunction> Functions) { @@ -1600,6 +1611,7 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm, writeEventSection(Events); writeExportSection(Exports); writeElemSection(TableElems); + writeDataCountSection(); writeCodeSection(Asm, Layout, Functions); writeDataSection(); for (auto &CustomSection : CustomSections) |