Path: blob/main/contrib/llvm-project/llvm/lib/ObjCopy/wasm/WasmObject.h
35266 views
//===- WasmObject.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_WASMOBJECT_H9#define LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H1011#include "llvm/ADT/ArrayRef.h"12#include "llvm/ADT/StringRef.h"13#include "llvm/Object/Wasm.h"14#include "llvm/Support/MemoryBuffer.h"15#include <vector>1617namespace llvm {18namespace objcopy {19namespace wasm {2021struct Section {22// For now, each section is only an opaque binary blob with no distinction23// between custom and known sections.24uint8_t SectionType;25std::optional<uint8_t> HeaderSecSizeEncodingLen;26StringRef Name;27ArrayRef<uint8_t> Contents;28};2930struct Object {31llvm::wasm::WasmObjectHeader Header;32// For now don't discriminate between kinds of sections.33std::vector<Section> Sections;3435void addSectionWithOwnedContents(Section NewSection,36std::unique_ptr<MemoryBuffer> &&Content);37void removeSections(function_ref<bool(const Section &)> ToRemove);3839private:40std::vector<std::unique_ptr<MemoryBuffer>> OwnedContents;41};4243} // end namespace wasm44} // end namespace objcopy45} // end namespace llvm4647#endif // LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H484950