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