1 //===- ARMEmulation.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 "ARM.h" 10 #include "mcld/LinkerConfig.h" 11 #include "mcld/LinkerScript.h" 12 #include "mcld/Target/ELFEmulation.h" 13 #include "mcld/Support/TargetRegistry.h" 14 15 namespace mcld { 16 17 static bool MCLDEmulateARMELF(LinkerScript& pScript, LinkerConfig& pConfig) { 18 if (!MCLDEmulateELF(pScript, 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 35 // set up section map 36 if (pConfig.options().getScriptList().empty() && 37 pConfig.codeGenType() != LinkerConfig::Object) { 38 pScript.sectionMap().insert(".ARM.exidx*", ".ARM.exidx"); 39 pScript.sectionMap().insert(".ARM.extab*", ".ARM.extab"); 40 pScript.sectionMap().insert(".ARM.attributes*", ".ARM.attributes"); 41 } 42 return true; 43 } 44 45 //===----------------------------------------------------------------------===// 46 // emulateARMLD - the help function to emulate ARM ld 47 //===----------------------------------------------------------------------===// 48 bool emulateARMLD(LinkerScript& pScript, LinkerConfig& pConfig) { 49 if (pConfig.targets().triple().isOSDarwin()) { 50 assert(0 && "MachO linker has not supported yet"); 51 return false; 52 } 53 if (pConfig.targets().triple().isOSWindows()) { 54 assert(0 && "COFF linker has not supported yet"); 55 return false; 56 } 57 58 return MCLDEmulateARMELF(pScript, pConfig); 59 } 60 61 } // namespace mcld 62 63 //===----------------------------------------------------------------------===// 64 // ARMEmulation 65 //===----------------------------------------------------------------------===// 66 extern "C" void MCLDInitializeARMEmulation() { 67 // Register the emulation 68 mcld::TargetRegistry::RegisterEmulation(mcld::TheARMTarget, 69 mcld::emulateARMLD); 70 mcld::TargetRegistry::RegisterEmulation(mcld::TheThumbTarget, 71 mcld::emulateARMLD); 72 } 73