]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/include/lld/Core/SharedLibraryFile.h
Bring lld (release_39 branch, r279477) to contrib
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / include / lld / Core / SharedLibraryFile.h
1 //===- Core/SharedLibraryFile.h - Models shared libraries as Atoms --------===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLD_CORE_SHARED_LIBRARY_FILE_H
11 #define LLD_CORE_SHARED_LIBRARY_FILE_H
12
13 #include "lld/Core/File.h"
14
15 namespace lld {
16
17 ///
18 /// The SharedLibraryFile subclass of File is used to represent dynamic
19 /// shared libraries being linked against.
20 ///
21 class SharedLibraryFile : public File {
22 public:
23   static bool classof(const File *f) {
24     return f->kind() == kindSharedLibrary;
25   }
26
27   /// Check if the shared library exports a symbol with the specified name.
28   /// If so, return a SharedLibraryAtom which represents that exported
29   /// symbol.  Otherwise return nullptr.
30   virtual OwningAtomPtr<SharedLibraryAtom> exports(StringRef name) const = 0;
31
32   // Returns the install name.
33   virtual StringRef getDSOName() const = 0;
34
35   const AtomRange<DefinedAtom> defined() const override {
36     return _definedAtoms;
37   }
38
39   const AtomRange<UndefinedAtom> undefined() const override {
40     return _undefinedAtoms;
41   }
42
43   const AtomRange<SharedLibraryAtom> sharedLibrary() const override {
44     return _sharedLibraryAtoms;
45   }
46
47   const AtomRange<AbsoluteAtom> absolute() const override {
48     return _absoluteAtoms;
49   }
50
51   void clearAtoms() override {
52     _definedAtoms.clear();
53     _undefinedAtoms.clear();
54     _sharedLibraryAtoms.clear();
55     _absoluteAtoms.clear();
56   }
57
58 protected:
59   /// only subclasses of SharedLibraryFile can be instantiated
60   explicit SharedLibraryFile(StringRef path) : File(path, kindSharedLibrary) {}
61
62   AtomVector<DefinedAtom> _definedAtoms;
63   AtomVector<UndefinedAtom> _undefinedAtoms;
64   AtomVector<SharedLibraryAtom> _sharedLibraryAtoms;
65   AtomVector<AbsoluteAtom> _absoluteAtoms;
66 };
67
68 } // namespace lld
69
70 #endif // LLD_CORE_SHARED_LIBRARY_FILE_H