2022-02-22 22:56:22 +03:00
|
|
|
//===- WasmObject.h ---------------------------------------------*- C++ -*-===//
|
2020-01-29 17:30:57 -08:00
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2022-02-22 22:56:22 +03:00
|
|
|
#ifndef LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H
|
|
|
|
#define LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H
|
2020-01-29 17:30:57 -08:00
|
|
|
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Object/Wasm.h"
|
2020-02-11 15:13:40 -08:00
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
2020-01-29 17:30:57 -08:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace objcopy {
|
|
|
|
namespace wasm {
|
|
|
|
|
|
|
|
struct Section {
|
|
|
|
// For now, each section is only an opaque binary blob with no distinction
|
|
|
|
// between custom and known sections.
|
|
|
|
uint8_t SectionType;
|
2023-07-25 14:13:05 -07:00
|
|
|
std::optional<uint8_t> HeaderSecSizeEncodingLen;
|
2020-01-29 17:30:57 -08:00
|
|
|
StringRef Name;
|
|
|
|
ArrayRef<uint8_t> Contents;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Object {
|
|
|
|
llvm::wasm::WasmObjectHeader Header;
|
|
|
|
// For now don't discriminate between kinds of sections.
|
|
|
|
std::vector<Section> Sections;
|
2020-02-11 15:13:40 -08:00
|
|
|
|
|
|
|
void addSectionWithOwnedContents(Section NewSection,
|
|
|
|
std::unique_ptr<MemoryBuffer> &&Content);
|
|
|
|
void removeSections(function_ref<bool(const Section &)> ToRemove);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<std::unique_ptr<MemoryBuffer>> OwnedContents;
|
2020-01-29 17:30:57 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace wasm
|
|
|
|
} // end namespace objcopy
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2022-02-22 22:56:22 +03:00
|
|
|
#endif // LLVM_LIB_OBJCOPY_WASM_WASMOBJECT_H
|