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/Compiler.h" 21 #include "llvm/Support/Error.h" 22 #include "llvm/Support/MemoryBufferRef.h" 23 #include "llvm/TextAPI/Architecture.h" 24 #include "llvm/TextAPI/InterfaceFile.h" 25 26 namespace llvm { 27 28 class raw_ostream; 29 30 namespace object { 31 32 class LLVM_ABI TapiFile : public SymbolicFile { 33 public: 34 TapiFile(MemoryBufferRef Source, const MachO::InterfaceFile &Interface, 35 MachO::Architecture Arch); 36 ~TapiFile() override; 37 38 void moveSymbolNext(DataRefImpl &DRI) const override; 39 40 Error printSymbolName(raw_ostream &OS, DataRefImpl DRI) const override; 41 42 Expected<uint32_t> getSymbolFlags(DataRefImpl DRI) const override; 43 44 basic_symbol_iterator symbol_begin() const override; 45 46 basic_symbol_iterator symbol_end() const override; 47 48 Expected<SymbolRef::Type> getSymbolType(DataRefImpl DRI) const; 49 hasSegmentInfo()50 bool hasSegmentInfo() { return FileKind >= MachO::FileType::TBD_V5; } 51 classof(const Binary * v)52 static bool classof(const Binary *v) { return v->isTapiFile(); } 53 is64Bit()54 bool is64Bit() const override { return MachO::is64Bit(Arch); } 55 56 private: 57 struct Symbol { 58 StringRef Prefix; 59 StringRef Name; 60 uint32_t Flags; 61 SymbolRef::Type Type; 62 SymbolSymbol63 constexpr Symbol(StringRef Prefix, StringRef Name, uint32_t Flags, 64 SymbolRef::Type Type) 65 : Prefix(Prefix), Name(Name), Flags(Flags), Type(Type) {} 66 }; 67 68 std::vector<Symbol> Symbols; 69 MachO::Architecture Arch; 70 MachO::FileType FileKind; 71 }; 72 73 } // end namespace object. 74 } // end namespace llvm. 75 76 #endif // LLVM_OBJECT_TAPIFILE_H 77