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