1 //===- Core/SharedLibraryAtom.h - A Shared Library Atom -------------------===// 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_ATOM_H 11 #define LLD_CORE_SHARED_LIBRARY_ATOM_H 12 13 #include "lld/Core/Atom.h" 14 15 namespace lld { 16 17 /// A SharedLibraryAtom has no content. 18 /// It exists to represent a symbol which will be bound at runtime. 19 class SharedLibraryAtom : public Atom { 20 public: 21 enum class Type : uint32_t { 22 Unknown, 23 Code, 24 Data, 25 }; 26 27 /// Returns shared library name used to load it at runtime. 28 /// On Darwin it is the LC_DYLIB_LOAD dylib name. 29 virtual StringRef loadName() const = 0; 30 31 /// Returns if shared library symbol can be missing at runtime and if 32 /// so the loader should silently resolve address of symbol to be nullptr. 33 virtual bool canBeNullAtRuntime() const = 0; 34 35 virtual Type type() const = 0; 36 37 virtual uint64_t size() const = 0; 38 39 static bool classof(const Atom *a) { 40 return a->definition() == definitionSharedLibrary; 41 } 42 43 static inline bool classof(const SharedLibraryAtom *) { return true; } 44 45 protected: 46 SharedLibraryAtom() : Atom(definitionSharedLibrary) {} 47 48 ~SharedLibraryAtom() override = default; 49 }; 50 51 } // namespace lld 52 53 #endif // LLD_CORE_SHARED_LIBRARY_ATOM_H 54