TapiFile.h 1.8 KB

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