1 //===- lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp ----------------------===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "X86TargetHandler.h"
11 #include "X86DynamicLibraryWriter.h"
12 #include "X86ExecutableWriter.h"
13 #include "X86LinkingContext.h"
14 #include "X86RelocationHandler.h"
19 using namespace llvm::ELF;
21 std::unique_ptr<Writer> X86TargetHandler::getWriter() {
22 switch (_x86LinkingContext.getOutputELFType()) {
23 case llvm::ELF::ET_EXEC:
24 return std::unique_ptr<Writer>(new X86ExecutableWriter<X86ELFType>(
25 _x86LinkingContext, *_x86TargetLayout.get()));
26 case llvm::ELF::ET_DYN:
27 return std::unique_ptr<Writer>(new X86DynamicLibraryWriter<X86ELFType>(
28 _x86LinkingContext, *_x86TargetLayout.get()));
29 case llvm::ELF::ET_REL:
30 llvm_unreachable("TODO: support -r mode");
32 llvm_unreachable("unsupported output type");
36 #define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
38 const Registry::KindStrings X86TargetHandler::kindStrings[] = {
39 #include "llvm/Support/ELFRelocs/i386.def"
45 void X86TargetHandler::registerRelocationNames(Registry ®istry) {
46 registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::x86,
50 X86TargetHandler::X86TargetHandler(X86LinkingContext &context)
51 : _x86LinkingContext(context),
52 _x86TargetLayout(new X86TargetLayout<X86ELFType>(context)),
53 _x86RelocationHandler(new X86TargetRelocationHandler()) {}