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