Path: blob/main/contrib/llvm-project/llvm/lib/ObjCopy/wasm/WasmWriter.h
35294 views
//===- WasmWriter.h ---------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_LIB_OBJCOPY_WASM_WASMWRITER_H9#define LLVM_LIB_OBJCOPY_WASM_WASMWRITER_H1011#include "WasmObject.h"12#include <cstdint>13#include <vector>1415namespace llvm {16namespace objcopy {17namespace wasm {1819class Writer {20public:21Writer(Object &Obj, raw_ostream &Out) : Obj(Obj), Out(Out) {}22Error write();2324private:25using SectionHeader = SmallVector<char, 8>;26Object &Obj;27raw_ostream &Out;28std::vector<SectionHeader> SectionHeaders;2930/// Generate a wasm section section header for S.31/// The header consists of32/// * A one-byte section ID (aka the section type).33/// * The size of the section contents, encoded as ULEB128.34/// * If the section is a custom section (type 0) it also has a name, which is35/// encoded as a length-prefixed string. The encoded section size *includes*36/// this string.37/// See https://webassembly.github.io/spec/core/binary/modules.html#sections38/// Return the header and store the total size in SectionSize.39static SectionHeader createSectionHeader(const Section &S,40size_t &SectionSize);41size_t finalize();42};4344} // end namespace wasm45} // end namespace objcopy46} // end namespace llvm4748#endif // LLVM_LIB_OBJCOPY_WASM_WASMWRITER_H495051