blob: 00a65ece0ad79dfe87d5fffa1cbcf3e2683aa0dc [file] [log] [blame]
//===- StubFactory.h ------------------------------------------------------===//
//
// The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MCLD_LD_STUB_FACTORY_H
#define MCLD_LD_STUB_FACTORY_H
#ifdef ENABLE_UNITTEST
#include <gtest.h>
#endif
#include <llvm/Support/DataTypes.h>
#include <vector>
namespace mcld
{
class Stub;
class Relocation;
class RelocationFactory;
class BranchIslandFactory;
class FragmentLinker;
/** \class StubFactory
* \brief the clone factory of Stub
*
*/
class StubFactory
{
public:
StubFactory();
~StubFactory();
/// addPrototype - register a stub prototype
void addPrototype(Stub* pPrototype);
/// create - create a stub if needed, otherwise return NULL
Stub* create(Relocation& pReloc,
uint64_t pTargetSymValue,
FragmentLinker& pLinker,
RelocationFactory& pRelocFactory,
BranchIslandFactory& pBRIslandFactory);
private:
/// findPrototype - find if there is a registered stub prototype for the given
/// relocation
Stub* findPrototype(const Relocation& pReloc,
const uint64_t pSource,
uint64_t pTargetSymValue);
private:
typedef std::vector<Stub*> StubPoolType;
private:
StubPoolType m_StubPool; // stub pool
};
} // namespace of mcld
#endif