20using namespace object;
23Writer::SectionHeader Writer::createSectionHeader(
const Section &S,
24 size_t &SectionSize) {
35 unsigned HeaderSecSizeEncodingLen =
36 S.HeaderSecSizeEncodingLen ? *S.HeaderSecSizeEncodingLen : 5;
48size_t Writer::finalize() {
50 SectionHeaders.reserve(Obj.
Sections.size());
52 for (
const Section &S : Obj.
Sections) {
54 SectionHeaders.push_back(createSectionHeader(S, SectionSize));
61 size_t TotalSize = finalize();
71 for (
size_t I = 0, S = SectionHeaders.size();
I < S; ++
I) {
72 Out.
write(SectionHeaders[
I].data(), SectionHeaders[
I].
size());
73 Out.
write(
reinterpret_cast<const char *
>(Obj.
Sections[
I].Contents.data()),
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
raw_ostream & write(unsigned char C)
virtual void reserveExtraSpace(uint64_t ExtraSize)
If possible, pre-allocate ExtraSize bytes for stream data.
A raw_ostream that writes to an SmallVector or SmallString.
void write32le(void *P, uint32_t V)
const uint32_t WasmVersion
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
std::vector< Section > Sections
llvm::wasm::WasmObjectHeader Header