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