1//===- Resolver.h ---------------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_LD_RESOLVER_H_ 10#define MCLD_LD_RESOLVER_H_ 11#include "mcld/LD/LDSymbol.h" 12 13#include <string> 14#include <utility> 15 16namespace mcld { 17 18class NamePool; 19class ResolveInfo; 20 21/** \class Resolver 22 * \brief Resolver binds a symbol reference from one file to a symbol 23 * definition of another file. 24 * 25 * Resolver seals up the algorithm of symbol resolution. The resolution of 26 * two symbols depends on their type, binding and whether it is belonging to 27 * a shared object. 28 */ 29class Resolver { 30 public: 31 enum Action { Success, Warning, Abort, LastAction }; 32 33 /** \class Resolver::Result 34 * \brief the result of symbol resolution 35 * - info, the pointer to overrided info 36 * - existent, if true, the info is existent 37 * - overriden, if true, the info is being overriden. 38 */ 39 struct Result { 40 ResolveInfo* info; 41 bool existent; 42 bool overriden; 43 }; 44 45 public: 46 virtual ~Resolver(); 47 48 /// shouldOverride - Can resolver override the symbol pOld by the symbol pNew? 49 /// @return the action should be taken. 50 /// @param pOld the symbol which may be overridden. 51 /// @param pNew the symbol which is used to replace pOld 52 virtual bool resolve(ResolveInfo& __restrict__ pOld, 53 const ResolveInfo& __restrict__ pNew, 54 bool& pOverride, 55 LDSymbol::ValueType pValue) const = 0; 56 57 /// resolveAgain - Can override by derived classes. 58 /// @return the pointer to resolved ResolveInfo 59 /// @return is the symbol existent? 60 virtual void resolveAgain(NamePool& pNamePool, 61 unsigned int pAction, 62 ResolveInfo& __restrict__ pOld, 63 const ResolveInfo& __restrict__ pNew, 64 Result& pResult) const { 65 pResult.info = NULL; 66 pResult.existent = false; 67 pResult.overriden = false; 68 } 69}; 70 71} // namespace mcld 72 73#endif // MCLD_LD_RESOLVER_H_ 74