1 //===- Core/SharedLibraryFile.h - Models shared libraries as Atoms --------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_CORE_SHARED_LIBRARY_FILE_H
10 #define LLD_CORE_SHARED_LIBRARY_FILE_H
12 #include "lld/Core/File.h"
17 /// The SharedLibraryFile subclass of File is used to represent dynamic
18 /// shared libraries being linked against.
20 class SharedLibraryFile : public File {
22 static bool classof(const File *f) {
23 return f->kind() == kindSharedLibrary;
26 /// Check if the shared library exports a symbol with the specified name.
27 /// If so, return a SharedLibraryAtom which represents that exported
28 /// symbol. Otherwise return nullptr.
29 virtual OwningAtomPtr<SharedLibraryAtom> exports(StringRef name) const = 0;
31 // Returns the install name.
32 virtual StringRef getDSOName() const = 0;
34 const AtomRange<DefinedAtom> defined() const override {
38 const AtomRange<UndefinedAtom> undefined() const override {
39 return _undefinedAtoms;
42 const AtomRange<SharedLibraryAtom> sharedLibrary() const override {
43 return _sharedLibraryAtoms;
46 const AtomRange<AbsoluteAtom> absolute() const override {
47 return _absoluteAtoms;
50 void clearAtoms() override {
51 _definedAtoms.clear();
52 _undefinedAtoms.clear();
53 _sharedLibraryAtoms.clear();
54 _absoluteAtoms.clear();
58 /// only subclasses of SharedLibraryFile can be instantiated
59 explicit SharedLibraryFile(StringRef path) : File(path, kindSharedLibrary) {}
61 AtomVector<DefinedAtom> _definedAtoms;
62 AtomVector<UndefinedAtom> _undefinedAtoms;
63 AtomVector<SharedLibraryAtom> _sharedLibraryAtoms;
64 AtomVector<AbsoluteAtom> _absoluteAtoms;
69 #endif // LLD_CORE_SHARED_LIBRARY_FILE_H