#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/Error.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/SymbolicFile.h"
#include "llvm/Object/Wasm.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/TargetParser/SubtargetFeature.h"
#include "llvm/TargetParser/Triple.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <limits>
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespaceobject;
void WasmSymbol::print(raw_ostream &Out) const { … }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void WasmSymbol::dump() const { print(dbgs()); }
#endif
Expected<std::unique_ptr<WasmObjectFile>>
ObjectFile::createWasmObjectFile(MemoryBufferRef Buffer) { … }
#define VARINT7_MAX …
#define VARINT7_MIN …
#define VARUINT7_MAX …
#define VARUINT1_MAX …
static uint8_t readUint8(WasmObjectFile::ReadContext &Ctx) { … }
static uint32_t readUint32(WasmObjectFile::ReadContext &Ctx) { … }
static int32_t readFloat32(WasmObjectFile::ReadContext &Ctx) { … }
static int64_t readFloat64(WasmObjectFile::ReadContext &Ctx) { … }
static uint64_t readULEB128(WasmObjectFile::ReadContext &Ctx) { … }
static StringRef readString(WasmObjectFile::ReadContext &Ctx) { … }
static int64_t readLEB128(WasmObjectFile::ReadContext &Ctx) { … }
static uint8_t readVaruint1(WasmObjectFile::ReadContext &Ctx) { … }
static int32_t readVarint32(WasmObjectFile::ReadContext &Ctx) { … }
static uint32_t readVaruint32(WasmObjectFile::ReadContext &Ctx) { … }
static int64_t readVarint64(WasmObjectFile::ReadContext &Ctx) { … }
static uint64_t readVaruint64(WasmObjectFile::ReadContext &Ctx) { … }
static uint8_t readOpcode(WasmObjectFile::ReadContext &Ctx) { … }
static wasm::ValType parseValType(WasmObjectFile::ReadContext &Ctx,
uint32_t Code) { … }
static Error readInitExpr(wasm::WasmInitExpr &Expr,
WasmObjectFile::ReadContext &Ctx) { … }
static wasm::WasmLimits readLimits(WasmObjectFile::ReadContext &Ctx) { … }
static wasm::WasmTableType readTableType(WasmObjectFile::ReadContext &Ctx) { … }
static Error readSection(WasmSection &Section, WasmObjectFile::ReadContext &Ctx,
WasmSectionOrderChecker &Checker) { … }
WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
: … { … }
Error WasmObjectFile::parseSection(WasmSection &Sec) { … }
Error WasmObjectFile::parseDylinkSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseDylink0Section(ReadContext &Ctx) { … }
Error WasmObjectFile::parseNameSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseLinkingSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) { … }
Error WasmObjectFile::parseLinkingSectionComdat(ReadContext &Ctx) { … }
Error WasmObjectFile::parseProducersSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseTargetFeaturesSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) { … }
Error WasmObjectFile::parseCustomSection(WasmSection &Sec, ReadContext &Ctx) { … }
Error WasmObjectFile::parseTypeSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseImportSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseFunctionSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseTableSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseMemorySection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseTagSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseGlobalSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseExportSection(ReadContext &Ctx) { … }
bool WasmObjectFile::isValidFunctionIndex(uint32_t Index) const { … }
bool WasmObjectFile::isDefinedFunctionIndex(uint32_t Index) const { … }
bool WasmObjectFile::isValidGlobalIndex(uint32_t Index) const { … }
bool WasmObjectFile::isValidTableNumber(uint32_t Index) const { … }
bool WasmObjectFile::isDefinedGlobalIndex(uint32_t Index) const { … }
bool WasmObjectFile::isDefinedTableNumber(uint32_t Index) const { … }
bool WasmObjectFile::isValidTagIndex(uint32_t Index) const { … }
bool WasmObjectFile::isDefinedTagIndex(uint32_t Index) const { … }
bool WasmObjectFile::isValidFunctionSymbol(uint32_t Index) const { … }
bool WasmObjectFile::isValidTableSymbol(uint32_t Index) const { … }
bool WasmObjectFile::isValidGlobalSymbol(uint32_t Index) const { … }
bool WasmObjectFile::isValidTagSymbol(uint32_t Index) const { … }
bool WasmObjectFile::isValidDataSymbol(uint32_t Index) const { … }
bool WasmObjectFile::isValidSectionSymbol(uint32_t Index) const { … }
wasm::WasmFunction &WasmObjectFile::getDefinedFunction(uint32_t Index) { … }
const wasm::WasmFunction &
WasmObjectFile::getDefinedFunction(uint32_t Index) const { … }
const wasm::WasmGlobal &WasmObjectFile::getDefinedGlobal(uint32_t Index) const { … }
wasm::WasmTag &WasmObjectFile::getDefinedTag(uint32_t Index) { … }
Error WasmObjectFile::parseStartSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseCodeSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseElemSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseDataSection(ReadContext &Ctx) { … }
Error WasmObjectFile::parseDataCountSection(ReadContext &Ctx) { … }
const wasm::WasmObjectHeader &WasmObjectFile::getHeader() const { … }
void WasmObjectFile::moveSymbolNext(DataRefImpl &Symb) const { … }
Expected<uint32_t> WasmObjectFile::getSymbolFlags(DataRefImpl Symb) const { … }
basic_symbol_iterator WasmObjectFile::symbol_begin() const { … }
basic_symbol_iterator WasmObjectFile::symbol_end() const { … }
const WasmSymbol &WasmObjectFile::getWasmSymbol(const DataRefImpl &Symb) const { … }
const WasmSymbol &WasmObjectFile::getWasmSymbol(const SymbolRef &Symb) const { … }
Expected<StringRef> WasmObjectFile::getSymbolName(DataRefImpl Symb) const { … }
Expected<uint64_t> WasmObjectFile::getSymbolAddress(DataRefImpl Symb) const { … }
uint64_t WasmObjectFile::getWasmSymbolValue(const WasmSymbol &Sym) const { … }
uint64_t WasmObjectFile::getSymbolValueImpl(DataRefImpl Symb) const { … }
uint32_t WasmObjectFile::getSymbolAlignment(DataRefImpl Symb) const { … }
uint64_t WasmObjectFile::getCommonSymbolSizeImpl(DataRefImpl Symb) const { … }
Expected<SymbolRef::Type>
WasmObjectFile::getSymbolType(DataRefImpl Symb) const { … }
Expected<section_iterator>
WasmObjectFile::getSymbolSection(DataRefImpl Symb) const { … }
uint32_t WasmObjectFile::getSymbolSectionId(SymbolRef Symb) const { … }
uint32_t WasmObjectFile::getSymbolSectionIdImpl(const WasmSymbol &Sym) const { … }
uint32_t WasmObjectFile::getSymbolSize(SymbolRef Symb) const { … }
void WasmObjectFile::moveSectionNext(DataRefImpl &Sec) const { … }
Expected<StringRef> WasmObjectFile::getSectionName(DataRefImpl Sec) const { … }
uint64_t WasmObjectFile::getSectionAddress(DataRefImpl Sec) const { … }
uint64_t WasmObjectFile::getSectionIndex(DataRefImpl Sec) const { … }
uint64_t WasmObjectFile::getSectionSize(DataRefImpl Sec) const { … }
Expected<ArrayRef<uint8_t>>
WasmObjectFile::getSectionContents(DataRefImpl Sec) const { … }
uint64_t WasmObjectFile::getSectionAlignment(DataRefImpl Sec) const { … }
bool WasmObjectFile::isSectionCompressed(DataRefImpl Sec) const { … }
bool WasmObjectFile::isSectionText(DataRefImpl Sec) const { … }
bool WasmObjectFile::isSectionData(DataRefImpl Sec) const { … }
bool WasmObjectFile::isSectionBSS(DataRefImpl Sec) const { … }
bool WasmObjectFile::isSectionVirtual(DataRefImpl Sec) const { … }
relocation_iterator WasmObjectFile::section_rel_begin(DataRefImpl Ref) const { … }
relocation_iterator WasmObjectFile::section_rel_end(DataRefImpl Ref) const { … }
void WasmObjectFile::moveRelocationNext(DataRefImpl &Rel) const { … }
uint64_t WasmObjectFile::getRelocationOffset(DataRefImpl Ref) const { … }
symbol_iterator WasmObjectFile::getRelocationSymbol(DataRefImpl Ref) const { … }
uint64_t WasmObjectFile::getRelocationType(DataRefImpl Ref) const { … }
void WasmObjectFile::getRelocationTypeName(
DataRefImpl Ref, SmallVectorImpl<char> &Result) const { … }
section_iterator WasmObjectFile::section_begin() const { … }
section_iterator WasmObjectFile::section_end() const { … }
uint8_t WasmObjectFile::getBytesInAddress() const { … }
StringRef WasmObjectFile::getFileFormatName() const { … }
Triple::ArchType WasmObjectFile::getArch() const { … }
Expected<SubtargetFeatures> WasmObjectFile::getFeatures() const { … }
bool WasmObjectFile::isRelocatableObject() const { … }
bool WasmObjectFile::isSharedObject() const { … }
const WasmSection &WasmObjectFile::getWasmSection(DataRefImpl Ref) const { … }
const WasmSection &
WasmObjectFile::getWasmSection(const SectionRef &Section) const { … }
const wasm::WasmRelocation &
WasmObjectFile::getWasmRelocation(const RelocationRef &Ref) const { … }
const wasm::WasmRelocation &
WasmObjectFile::getWasmRelocation(DataRefImpl Ref) const { … }
int WasmSectionOrderChecker::getSectionOrder(unsigned ID,
StringRef CustomSectionName) { … }
int WasmSectionOrderChecker::DisallowedPredecessors
[WASM_NUM_SEC_ORDERS][WASM_NUM_SEC_ORDERS] = …;
bool WasmSectionOrderChecker::isValidSectionOrder(unsigned ID,
StringRef CustomSectionName) { … }