X86MCLinker.cpp revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
1//===- X86MCLinker.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 "X86.h"
10#include "X86ELFMCLinker.h"
11#include <mcld/Module.h>
12#include <mcld/Support/TargetRegistry.h>
13#include <llvm/ADT/Triple.h>
14
15using namespace mcld;
16
17namespace mcld {
18
19//===----------------------------------------------------------------------===//
20/// createX86MCLinker - the help funtion to create corresponding X86MCLinker
21//===----------------------------------------------------------------------===//
22MCLinker* createX86MCLinker(const std::string &pTriple,
23                            LinkerConfig& pConfig,
24                            mcld::Module& pModule,
25                            MemoryArea& pOutput)
26{
27  Triple theTriple(pTriple);
28  if (theTriple.isOSDarwin()) {
29    assert(0 && "MachO linker has not supported yet");
30    return NULL;
31  }
32  if (theTriple.isOSWindows()) {
33    assert(0 && "COFF linker has not supported yet");
34    return NULL;
35  }
36
37  if (theTriple.isArch32Bit())
38    return new X86ELFMCLinker(pConfig, pModule, pOutput);
39
40  assert(0 && "X86_64 has not supported yet");
41  return NULL;
42}
43
44} // namespace of mcld
45
46//===----------------------------------------------------------------------===//
47// X86MCLinker
48//===----------------------------------------------------------------------===//
49extern "C" void MCLDInitializeX86MCLinker() {
50  // Register the linker frontend
51  mcld::TargetRegistry::RegisterMCLinker(TheX86Target, createX86MCLinker);
52}
53
54