1 //===- lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp ----------------===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "X86_64DynamicLibraryWriter.h"
12 #include "X86_64ExecutableWriter.h"
13 #include "X86_64LinkingContext.h"
14 #include "X86_64TargetHandler.h"
19 X86_64TargetHandler::X86_64TargetHandler(X86_64LinkingContext &context)
20 : _context(context), _x86_64TargetLayout(new X86_64TargetLayout(context)),
21 _x86_64RelocationHandler(
22 new X86_64TargetRelocationHandler(*_x86_64TargetLayout.get())) {}
24 void X86_64TargetHandler::registerRelocationNames(Registry ®istry) {
25 registry.addKindTable(Reference::KindNamespace::ELF,
26 Reference::KindArch::x86_64, kindStrings);
29 std::unique_ptr<Writer> X86_64TargetHandler::getWriter() {
30 switch (this->_context.getOutputELFType()) {
31 case llvm::ELF::ET_EXEC:
32 return std::unique_ptr<Writer>(
33 new X86_64ExecutableWriter(_context, *_x86_64TargetLayout.get()));
34 case llvm::ELF::ET_DYN:
35 return std::unique_ptr<Writer>(
36 new X86_64DynamicLibraryWriter(_context, *_x86_64TargetLayout.get()));
37 case llvm::ELF::ET_REL:
38 llvm_unreachable("TODO: support -r mode");
40 llvm_unreachable("unsupported output type");
44 #define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
46 const Registry::KindStrings X86_64TargetHandler::kindStrings[] = {
47 #include "llvm/Support/ELFRelocs/x86_64.def"
48 LLD_KIND_STRING_ENTRY(LLD_R_X86_64_GOTRELINDEX),