1 //===- TapiFile.h - Text-based Dynamic Library Stub -------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file declares the TapiFile interface. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_OBJECT_TAPIFILE_H 14 #define LLVM_OBJECT_TAPIFILE_H 15 16 #include "llvm/ADT/StringRef.h" 17 #include "llvm/Object/Binary.h" 18 #include "llvm/Object/ObjectFile.h" 19 #include "llvm/Object/SymbolicFile.h" 20 #include "llvm/Support/Error.h" 21 #include "llvm/Support/MemoryBufferRef.h" 22 #include "llvm/TextAPI/Architecture.h" 23 24 namespace llvm { 25 26 class raw_ostream; 27 28 namespace MachO { 29 30 class InterfaceFile; 31 32 } 33 34 namespace object { 35 36 class TapiFile : public SymbolicFile { 37 public: 38 TapiFile(MemoryBufferRef Source, const MachO::InterfaceFile &Interface, 39 MachO::Architecture Arch); 40 ~TapiFile() override; 41 42 void moveSymbolNext(DataRefImpl &DRI) const override; 43 44 Error printSymbolName(raw_ostream &OS, DataRefImpl DRI) const override; 45 46 Expected<uint32_t> getSymbolFlags(DataRefImpl DRI) const override; 47 48 basic_symbol_iterator symbol_begin() const override; 49 50 basic_symbol_iterator symbol_end() const override; 51 52 Expected<SymbolRef::Type> getSymbolType(DataRefImpl DRI) const; 53 54 static bool classof(const Binary *v) { return v->isTapiFile(); } 55 56 bool is64Bit() const override { return MachO::is64Bit(Arch); } 57 58 private: 59 struct Symbol { 60 StringRef Prefix; 61 StringRef Name; 62 uint32_t Flags; 63 SymbolRef::Type Type; 64 65 constexpr Symbol(StringRef Prefix, StringRef Name, uint32_t Flags, 66 SymbolRef::Type Type) 67 : Prefix(Prefix), Name(Name), Flags(Flags), Type(Type) {} 68 }; 69 70 std::vector<Symbol> Symbols; 71 MachO::Architecture Arch; 72 }; 73 74 } // end namespace object. 75 } // end namespace llvm. 76 77 #endif // LLVM_OBJECT_TAPIFILE_H 78