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