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