diff options
Diffstat (limited to 'include/llvm/Object/Wasm.h')
-rw-r--r-- | include/llvm/Object/Wasm.h | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/include/llvm/Object/Wasm.h b/include/llvm/Object/Wasm.h index 10edc461b9e9c..9d53131234f43 100644 --- a/include/llvm/Object/Wasm.h +++ b/include/llvm/Object/Wasm.h @@ -19,6 +19,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringMap.h" #include "llvm/BinaryFormat/Wasm.h" #include "llvm/Object/Binary.h" #include "llvm/Object/ObjectFile.h" @@ -48,7 +49,24 @@ public: StringRef Name; SymbolType Type; uint32_t Section; + uint32_t Flags = 0; + + // Index into the imports, exports or functions array of the object depending + // on the type uint32_t ElementIndex; + + bool isWeak() const { + return Flags & wasm::WASM_SYMBOL_FLAG_WEAK; + } + + void print(raw_ostream &Out) const { + Out << "Name=" << Name << ", Type=" << static_cast<int>(Type) + << ", Flags=" << Flags; + } + +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) + LLVM_DUMP_METHOD void dump() const { print(dbgs()); } +#endif }; class WasmSection { @@ -63,6 +81,7 @@ public: }; class WasmObjectFile : public ObjectFile { + public: WasmObjectFile(MemoryBufferRef Object, Error &Err); @@ -176,6 +195,7 @@ private: // Custom section types Error parseNameSection(const uint8_t *Ptr, const uint8_t *End); + Error parseLinkingSection(const uint8_t *Ptr, const uint8_t *End); Error parseRelocSection(StringRef Name, const uint8_t *Ptr, const uint8_t *End); @@ -190,13 +210,22 @@ private: std::vector<wasm::WasmExport> Exports; std::vector<wasm::WasmElemSegment> ElemSegments; std::vector<wasm::WasmDataSegment> DataSegments; - std::vector<WasmSymbol> Symbols; std::vector<wasm::WasmFunction> Functions; + std::vector<WasmSymbol> Symbols; ArrayRef<uint8_t> CodeSection; uint32_t StartFunction = -1; + + StringMap<uint32_t> SymbolMap; }; } // end namespace object + +inline raw_ostream &operator<<(raw_ostream &OS, + const object::WasmSymbol &Sym) { + Sym.print(OS); + return OS; +} + } // end namespace llvm #endif // LLVM_OBJECT_WASM_H |