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/ADT/iterator_range.h" 18 #include "llvm/Object/SymbolicFile.h" 19 #include "llvm/Support/Error.h" 20 #include "llvm/Support/MemoryBuffer.h" 21 #include "llvm/TextAPI/InterfaceFile.h" 22 23 namespace llvm { 24 namespace object { 25 26 class TapiFile : public SymbolicFile { 27 public: 28 TapiFile(MemoryBufferRef Source, const MachO::InterfaceFile &interface, 29 MachO::Architecture Arch); 30 ~TapiFile() override; 31 32 void moveSymbolNext(DataRefImpl &DRI) const override; 33 34 Error printSymbolName(raw_ostream &OS, DataRefImpl DRI) const override; 35 36 Expected<uint32_t> getSymbolFlags(DataRefImpl DRI) const override; 37 38 basic_symbol_iterator symbol_begin() const override; 39 40 basic_symbol_iterator symbol_end() const override; 41 42 static bool classof(const Binary *v) { return v->isTapiFile(); } 43 44 bool is64Bit() { return MachO::is64Bit(Arch); } 45 46 private: 47 struct Symbol { 48 StringRef Prefix; 49 StringRef Name; 50 uint32_t Flags; 51 52 constexpr Symbol(StringRef Prefix, StringRef Name, uint32_t Flags) 53 : Prefix(Prefix), Name(Name), Flags(Flags) {} 54 }; 55 56 std::vector<Symbol> Symbols; 57 MachO::Architecture Arch; 58 }; 59 60 } // end namespace object. 61 } // end namespace llvm. 62 63 #endif // LLVM_OBJECT_TAPIFILE_H 64