MipsEmulation.cpp revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
1//===- MipsEmulation.cpp --------------------------------------------------===// 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#include "Mips.h" 10#include <mcld/LinkerConfig.h> 11#include <mcld/Target/ELFEmulation.h> 12#include <mcld/Support/TargetRegistry.h> 13 14namespace mcld { 15 16static bool MCLDEmulateMipsELF(LinkerConfig& pConfig) 17{ 18 if (!MCLDEmulateELF(pConfig)) 19 return false; 20 21 // set up target-dependent constraints of attributes 22 pConfig.attribute().constraint().enableWholeArchive(); 23 pConfig.attribute().constraint().enableAsNeeded(); 24 pConfig.attribute().constraint().setSharedSystem(); 25 26 // set up the predefined attributes 27 pConfig.attribute().predefined().unsetWholeArchive(); 28 pConfig.attribute().predefined().unsetAsNeeded(); 29 pConfig.attribute().predefined().setDynamic(); 30 return true; 31} 32 33//===----------------------------------------------------------------------===// 34// emulateMipsLD - the help function to emulate Mips ld 35//===----------------------------------------------------------------------===// 36bool emulateMipsLD(const std::string& pTriple, LinkerConfig& pConfig) 37{ 38 llvm::Triple theTriple(pTriple); 39 if (theTriple.isOSDarwin()) { 40 assert(0 && "MachO linker has not supported yet"); 41 return false; 42 } 43 if (theTriple.isOSWindows()) { 44 assert(0 && "COFF linker has not supported yet"); 45 return false; 46 } 47 48 return MCLDEmulateMipsELF(pConfig); 49} 50 51} // namespace of mcld 52 53//===----------------------------------------------------------------------===// 54// MipsEmulation 55//===----------------------------------------------------------------------===// 56extern "C" void MCLDInitializeMipsEmulation() { 57 // Register the emulation 58 mcld::TargetRegistry::RegisterEmulation(mcld::TheMipselTarget, mcld::emulateMipsLD); 59} 60 61