Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- JITSymbol.h - JIT symbol abstraction ---------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Abstraction for target process addresses. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_EXECUTIONENGINE_JITSYMBOL_H |
| 15 | #define LLVM_EXECUTIONENGINE_JITSYMBOL_H |
| 16 | |
| 17 | #include <algorithm> |
| 18 | #include <cassert> |
| 19 | #include <cstddef> |
| 20 | #include <cstdint> |
| 21 | #include <functional> |
| 22 | #include <map> |
| 23 | #include <set> |
| 24 | #include <string> |
| 25 | |
| 26 | #include "llvm/ADT/StringRef.h" |
| 27 | #include "llvm/Support/Error.h" |
| 28 | |
| 29 | namespace llvm { |
| 30 | |
| 31 | class GlobalValue; |
| 32 | |
| 33 | namespace object { |
| 34 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 35 | class SymbolRef; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 36 | |
| 37 | } // end namespace object |
| 38 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 39 | /// Represents an address in the target process's address space. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 40 | using JITTargetAddress = uint64_t; |
| 41 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 42 | /// Flags for symbols in the JIT. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 43 | class JITSymbolFlags { |
| 44 | public: |
| 45 | using UnderlyingType = uint8_t; |
| 46 | using TargetFlagsType = uint64_t; |
| 47 | |
| 48 | enum FlagNames : UnderlyingType { |
| 49 | None = 0, |
| 50 | HasError = 1U << 0, |
| 51 | Weak = 1U << 1, |
| 52 | Common = 1U << 2, |
| 53 | Absolute = 1U << 3, |
| 54 | Exported = 1U << 4, |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 55 | Callable = 1U << 5, |
| 56 | Lazy = 1U << 6, |
| 57 | Materializing = 1U << 7 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | static JITSymbolFlags stripTransientFlags(JITSymbolFlags Orig) { |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 61 | return static_cast<FlagNames>(Orig.Flags & ~Lazy & ~Materializing); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 62 | } |
| 63 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 64 | /// Default-construct a JITSymbolFlags instance. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 65 | JITSymbolFlags() = default; |
| 66 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 67 | /// Construct a JITSymbolFlags instance from the given flags. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 68 | JITSymbolFlags(FlagNames Flags) : Flags(Flags) {} |
| 69 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 70 | /// Construct a JITSymbolFlags instance from the given flags and target |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 71 | /// flags. |
| 72 | JITSymbolFlags(FlagNames Flags, TargetFlagsType TargetFlags) |
| 73 | : Flags(Flags), TargetFlags(TargetFlags) {} |
| 74 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 75 | /// Return true if there was an error retrieving this symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 76 | bool hasError() const { |
| 77 | return (Flags & HasError) == HasError; |
| 78 | } |
| 79 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 80 | /// Returns true if this is a lazy symbol. |
| 81 | /// This flag is used internally by the JIT APIs to track |
| 82 | /// materialization states. |
| 83 | bool isLazy() const { return Flags & Lazy; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 84 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 85 | /// Returns true if this symbol is in the process of being |
| 86 | /// materialized. |
| 87 | bool isMaterializing() const { return Flags & Materializing; } |
| 88 | |
| 89 | /// Returns true if this symbol is fully materialized. |
| 90 | /// (i.e. neither lazy, nor materializing). |
| 91 | bool isMaterialized() const { return !(Flags & (Lazy | Materializing)); } |
| 92 | |
| 93 | /// Returns true if the Weak flag is set. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 94 | bool isWeak() const { |
| 95 | return (Flags & Weak) == Weak; |
| 96 | } |
| 97 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 98 | /// Returns true if the Common flag is set. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 99 | bool isCommon() const { |
| 100 | return (Flags & Common) == Common; |
| 101 | } |
| 102 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 103 | /// Returns true if the symbol isn't weak or common. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 104 | bool isStrong() const { |
| 105 | return !isWeak() && !isCommon(); |
| 106 | } |
| 107 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 108 | /// Returns true if the Exported flag is set. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 109 | bool isExported() const { |
| 110 | return (Flags & Exported) == Exported; |
| 111 | } |
| 112 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 113 | /// Returns true if the given symbol is known to be callable. |
| 114 | bool isCallable() const { return (Flags & Callable) == Callable; } |
| 115 | |
| 116 | /// Implicitly convert to the underlying flags type. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 117 | operator UnderlyingType&() { return Flags; } |
| 118 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 119 | /// Implicitly convert to the underlying flags type. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 120 | operator const UnderlyingType&() const { return Flags; } |
| 121 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 122 | /// Return a reference to the target-specific flags. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 123 | TargetFlagsType& getTargetFlags() { return TargetFlags; } |
| 124 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 125 | /// Return a reference to the target-specific flags. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 126 | const TargetFlagsType& getTargetFlags() const { return TargetFlags; } |
| 127 | |
| 128 | /// Construct a JITSymbolFlags value based on the flags of the given global |
| 129 | /// value. |
| 130 | static JITSymbolFlags fromGlobalValue(const GlobalValue &GV); |
| 131 | |
| 132 | /// Construct a JITSymbolFlags value based on the flags of the given libobject |
| 133 | /// symbol. |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 134 | static Expected<JITSymbolFlags> |
| 135 | fromObjectSymbol(const object::SymbolRef &Symbol); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 136 | |
| 137 | private: |
| 138 | UnderlyingType Flags = None; |
| 139 | TargetFlagsType TargetFlags = 0; |
| 140 | }; |
| 141 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 142 | /// ARM-specific JIT symbol flags. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 143 | /// FIXME: This should be moved into a target-specific header. |
| 144 | class ARMJITSymbolFlags { |
| 145 | public: |
| 146 | ARMJITSymbolFlags() = default; |
| 147 | |
| 148 | enum FlagNames { |
| 149 | None = 0, |
| 150 | Thumb = 1 << 0 |
| 151 | }; |
| 152 | |
| 153 | operator JITSymbolFlags::TargetFlagsType&() { return Flags; } |
| 154 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 155 | static ARMJITSymbolFlags fromObjectSymbol(const object::SymbolRef &Symbol); |
| 156 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 157 | private: |
| 158 | JITSymbolFlags::TargetFlagsType Flags = 0; |
| 159 | }; |
| 160 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 161 | /// Represents a symbol that has been evaluated to an address already. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 162 | class JITEvaluatedSymbol { |
| 163 | public: |
| 164 | JITEvaluatedSymbol() = default; |
| 165 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 166 | /// Create a 'null' symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 167 | JITEvaluatedSymbol(std::nullptr_t) {} |
| 168 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 169 | /// Create a symbol for the given address and flags. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 170 | JITEvaluatedSymbol(JITTargetAddress Address, JITSymbolFlags Flags) |
| 171 | : Address(Address), Flags(Flags) {} |
| 172 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 173 | /// An evaluated symbol converts to 'true' if its address is non-zero. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 174 | explicit operator bool() const { return Address != 0; } |
| 175 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 176 | /// Return the address of this symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 177 | JITTargetAddress getAddress() const { return Address; } |
| 178 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 179 | /// Return the flags for this symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 180 | JITSymbolFlags getFlags() const { return Flags; } |
| 181 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 182 | /// Set the flags for this symbol. |
| 183 | void setFlags(JITSymbolFlags Flags) { this->Flags = std::move(Flags); } |
| 184 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 185 | private: |
| 186 | JITTargetAddress Address = 0; |
| 187 | JITSymbolFlags Flags; |
| 188 | }; |
| 189 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 190 | /// Represents a symbol in the JIT. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 191 | class JITSymbol { |
| 192 | public: |
| 193 | using GetAddressFtor = std::function<Expected<JITTargetAddress>()>; |
| 194 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 195 | /// Create a 'null' symbol, used to represent a "symbol not found" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 196 | /// result from a successful (non-erroneous) lookup. |
| 197 | JITSymbol(std::nullptr_t) |
| 198 | : CachedAddr(0) {} |
| 199 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 200 | /// Create a JITSymbol representing an error in the symbol lookup |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 201 | /// process (e.g. a network failure during a remote lookup). |
| 202 | JITSymbol(Error Err) |
| 203 | : Err(std::move(Err)), Flags(JITSymbolFlags::HasError) {} |
| 204 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 205 | /// Create a symbol for a definition with a known address. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 206 | JITSymbol(JITTargetAddress Addr, JITSymbolFlags Flags) |
| 207 | : CachedAddr(Addr), Flags(Flags) {} |
| 208 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 209 | /// Construct a JITSymbol from a JITEvaluatedSymbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 210 | JITSymbol(JITEvaluatedSymbol Sym) |
| 211 | : CachedAddr(Sym.getAddress()), Flags(Sym.getFlags()) {} |
| 212 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 213 | /// Create a symbol for a definition that doesn't have a known address |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 214 | /// yet. |
| 215 | /// @param GetAddress A functor to materialize a definition (fixing the |
| 216 | /// address) on demand. |
| 217 | /// |
| 218 | /// This constructor allows a JIT layer to provide a reference to a symbol |
| 219 | /// definition without actually materializing the definition up front. The |
| 220 | /// user can materialize the definition at any time by calling the getAddress |
| 221 | /// method. |
| 222 | JITSymbol(GetAddressFtor GetAddress, JITSymbolFlags Flags) |
| 223 | : GetAddress(std::move(GetAddress)), CachedAddr(0), Flags(Flags) {} |
| 224 | |
| 225 | JITSymbol(const JITSymbol&) = delete; |
| 226 | JITSymbol& operator=(const JITSymbol&) = delete; |
| 227 | |
| 228 | JITSymbol(JITSymbol &&Other) |
| 229 | : GetAddress(std::move(Other.GetAddress)), Flags(std::move(Other.Flags)) { |
| 230 | if (Flags.hasError()) |
| 231 | Err = std::move(Other.Err); |
| 232 | else |
| 233 | CachedAddr = std::move(Other.CachedAddr); |
| 234 | } |
| 235 | |
| 236 | JITSymbol& operator=(JITSymbol &&Other) { |
| 237 | GetAddress = std::move(Other.GetAddress); |
| 238 | Flags = std::move(Other.Flags); |
| 239 | if (Flags.hasError()) |
| 240 | Err = std::move(Other.Err); |
| 241 | else |
| 242 | CachedAddr = std::move(Other.CachedAddr); |
| 243 | return *this; |
| 244 | } |
| 245 | |
| 246 | ~JITSymbol() { |
| 247 | if (Flags.hasError()) |
| 248 | Err.~Error(); |
| 249 | else |
| 250 | CachedAddr.~JITTargetAddress(); |
| 251 | } |
| 252 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 253 | /// Returns true if the symbol exists, false otherwise. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 254 | explicit operator bool() const { |
| 255 | return !Flags.hasError() && (CachedAddr || GetAddress); |
| 256 | } |
| 257 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 258 | /// Move the error field value out of this JITSymbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 259 | Error takeError() { |
| 260 | if (Flags.hasError()) |
| 261 | return std::move(Err); |
| 262 | return Error::success(); |
| 263 | } |
| 264 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 265 | /// Get the address of the symbol in the target address space. Returns |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 266 | /// '0' if the symbol does not exist. |
| 267 | Expected<JITTargetAddress> getAddress() { |
| 268 | assert(!Flags.hasError() && "getAddress called on error value"); |
| 269 | if (GetAddress) { |
| 270 | if (auto CachedAddrOrErr = GetAddress()) { |
| 271 | GetAddress = nullptr; |
| 272 | CachedAddr = *CachedAddrOrErr; |
| 273 | assert(CachedAddr && "Symbol could not be materialized."); |
| 274 | } else |
| 275 | return CachedAddrOrErr.takeError(); |
| 276 | } |
| 277 | return CachedAddr; |
| 278 | } |
| 279 | |
| 280 | JITSymbolFlags getFlags() const { return Flags; } |
| 281 | |
| 282 | private: |
| 283 | GetAddressFtor GetAddress; |
| 284 | union { |
| 285 | JITTargetAddress CachedAddr; |
| 286 | Error Err; |
| 287 | }; |
| 288 | JITSymbolFlags Flags; |
| 289 | }; |
| 290 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 291 | /// Symbol resolution interface. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 292 | /// |
| 293 | /// Allows symbol flags and addresses to be looked up by name. |
| 294 | /// Symbol queries are done in bulk (i.e. you request resolution of a set of |
| 295 | /// symbols, rather than a single one) to reduce IPC overhead in the case of |
| 296 | /// remote JITing, and expose opportunities for parallel compilation. |
| 297 | class JITSymbolResolver { |
| 298 | public: |
| 299 | using LookupSet = std::set<StringRef>; |
| 300 | using LookupResult = std::map<StringRef, JITEvaluatedSymbol>; |
| 301 | using LookupFlagsResult = std::map<StringRef, JITSymbolFlags>; |
| 302 | |
| 303 | virtual ~JITSymbolResolver() = default; |
| 304 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 305 | /// Returns the fully resolved address and flags for each of the given |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 306 | /// symbols. |
| 307 | /// |
| 308 | /// This method will return an error if any of the given symbols can not be |
| 309 | /// resolved, or if the resolution process itself triggers an error. |
| 310 | virtual Expected<LookupResult> lookup(const LookupSet &Symbols) = 0; |
| 311 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 312 | /// Returns the symbol flags for each of the given symbols. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 313 | /// |
| 314 | /// This method does NOT return an error if any of the given symbols is |
| 315 | /// missing. Instead, that symbol will be left out of the result map. |
| 316 | virtual Expected<LookupFlagsResult> lookupFlags(const LookupSet &Symbols) = 0; |
| 317 | |
| 318 | private: |
| 319 | virtual void anchor(); |
| 320 | }; |
| 321 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 322 | /// Legacy symbol resolution interface. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 323 | class LegacyJITSymbolResolver : public JITSymbolResolver { |
| 324 | public: |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 325 | /// Performs lookup by, for each symbol, first calling |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 326 | /// findSymbolInLogicalDylib and if that fails calling |
| 327 | /// findSymbol. |
| 328 | Expected<LookupResult> lookup(const LookupSet &Symbols) final; |
| 329 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 330 | /// Performs flags lookup by calling findSymbolInLogicalDylib and |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 331 | /// returning the flags value for that symbol. |
| 332 | Expected<LookupFlagsResult> lookupFlags(const LookupSet &Symbols) final; |
| 333 | |
| 334 | /// This method returns the address of the specified symbol if it exists |
| 335 | /// within the logical dynamic library represented by this JITSymbolResolver. |
| 336 | /// Unlike findSymbol, queries through this interface should return addresses |
| 337 | /// for hidden symbols. |
| 338 | /// |
| 339 | /// This is of particular importance for the Orc JIT APIs, which support lazy |
| 340 | /// compilation by breaking up modules: Each of those broken out modules |
| 341 | /// must be able to resolve hidden symbols provided by the others. Clients |
| 342 | /// writing memory managers for MCJIT can usually ignore this method. |
| 343 | /// |
| 344 | /// This method will be queried by RuntimeDyld when checking for previous |
| 345 | /// definitions of common symbols. |
| 346 | virtual JITSymbol findSymbolInLogicalDylib(const std::string &Name) = 0; |
| 347 | |
| 348 | /// This method returns the address of the specified function or variable. |
| 349 | /// It is used to resolve symbols during module linking. |
| 350 | /// |
| 351 | /// If the returned symbol's address is equal to ~0ULL then RuntimeDyld will |
| 352 | /// skip all relocations for that symbol, and the client will be responsible |
| 353 | /// for handling them manually. |
| 354 | virtual JITSymbol findSymbol(const std::string &Name) = 0; |
| 355 | |
| 356 | private: |
| 357 | virtual void anchor(); |
| 358 | }; |
| 359 | |
| 360 | } // end namespace llvm |
| 361 | |
| 362 | #endif // LLVM_EXECUTIONENGINE_JITSYMBOL_H |