diff options
author | Derek Schuff <dschuff@google.com> | 2017-03-15 19:36:02 +0000 |
---|---|---|
committer | Derek Schuff <dschuff@google.com> | 2017-03-15 19:36:02 +0000 |
commit | 13f080fbebab4708afdaef542fda308d7a26a9c6 (patch) | |
tree | 8ea58068aff4a83cbe2ef651c09d80dac5ad844e /llvm/lib/MC/WasmObjectWriter.cpp | |
parent | 06c70adcf087f252559188f89fd6ec36d4801a88 (diff) | |
download | bcm5719-llvm-13f080fbebab4708afdaef542fda308d7a26a9c6.tar.gz bcm5719-llvm-13f080fbebab4708afdaef542fda308d7a26a9c6.zip |
[WebAssembly] Update format of 'names' section.
This change updates to the format of the 'names' sectionin the
generated wasm binary to match the latest changesto the design
and 'wabt'.
Differential Revision: https://reviews.llvm.org/D30950
Patch by Sam Clegg
llvm-svn: 297877
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/WasmObjectWriter.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 20ace61825b..39ddc30eb7d 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -982,25 +982,30 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm, } // === Name Section ========================================================== - if (NumFuncImports != 0 || !Functions.empty()) { + uint32_t TotalFunctions = NumFuncImports + Functions.size(); + if (TotalFunctions != 0) { startSection(Section, wasm::WASM_SEC_CUSTOM, "name"); + SectionBookkeeping SubSection; + startSection(SubSection, wasm::WASM_NAMES_FUNCTION); - encodeULEB128(NumFuncImports + Functions.size(), getStream()); + encodeULEB128(TotalFunctions, getStream()); + uint32_t Index = 0; for (const WasmImport &Import : Imports) { if (Import.Kind == wasm::WASM_EXTERNAL_FUNCTION) { + encodeULEB128(Index, getStream()); encodeULEB128(Import.FieldName.size(), getStream()); writeBytes(Import.FieldName); - encodeULEB128(0, getStream()); // local count, meaningless for imports + ++Index; } } for (const WasmFunction &Func : Functions) { + encodeULEB128(Index, getStream()); encodeULEB128(Func.Sym->getName().size(), getStream()); writeBytes(Func.Sym->getName()); - - // TODO: Local names. - encodeULEB128(0, getStream()); // local count + ++Index; } + endSection(SubSection); endSection(Section); } |