summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/WasmObjectWriter.cpp
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2019-04-12 22:27:48 +0000
committerThomas Lively <tlively@google.com>2019-04-12 22:27:48 +0000
commitfef8de66a6ad56d71eb8bf8a401f8cdc82dea225 (patch)
tree55b9ddd2be0fc7c1ac1ef4b1683aa44bee339bc8 /llvm/lib/MC/WasmObjectWriter.cpp
parentbdb5e4e4ca5fbc7ef528067b65dda298e191e059 (diff)
downloadbcm5719-llvm-fef8de66a6ad56d71eb8bf8a401f8cdc82dea225.tar.gz
bcm5719-llvm-fef8de66a6ad56d71eb8bf8a401f8cdc82dea225.zip
[WebAssembly] Add DataCount section to object files
Summary: This ensures that object files will continue to validate as WebAssembly modules in the presence of bulk memory operations. Engines that don't support bulk memory operations will not recognize the DataCount section and will report validation errors, but that's ok because object files aren't supposed to be run directly anyway. Reviewers: aheejin, dschuff, sbc100 Subscribers: jgravelle-google, hiraditya, sunfish, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60623 llvm-svn: 358315
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp12
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)
OpenPOWER on IntegriCloud