]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / lib / ReaderWriter / ELF / ARM / ARMTargetHandler.cpp
1 //===--------- lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp --------------===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "Atoms.h"
11 #include "ARMExecutableWriter.h"
12 #include "ARMTargetHandler.h"
13 #include "ARMLinkingContext.h"
14
15 using namespace lld;
16 using namespace elf;
17
18 ARMTargetHandler::ARMTargetHandler(ARMLinkingContext &context)
19     : _context(context), _armTargetLayout(
20           new ARMTargetLayout<ARMELFType>(context)),
21       _armRelocationHandler(new ARMTargetRelocationHandler(
22           *_armTargetLayout.get())) {}
23
24 void ARMTargetHandler::registerRelocationNames(Registry &registry) {
25   registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::ARM,
26                         kindStrings);
27 }
28
29 std::unique_ptr<Writer> ARMTargetHandler::getWriter() {
30   switch (this->_context.getOutputELFType()) {
31   case llvm::ELF::ET_EXEC:
32     return std::unique_ptr<Writer>(
33         new ARMExecutableWriter<ARMELFType>(_context, *_armTargetLayout.get()));
34   default:
35     llvm_unreachable("unsupported output type");
36   }
37 }
38
39 #define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
40
41 const Registry::KindStrings ARMTargetHandler::kindStrings[] = {
42 #include "llvm/Support/ELFRelocs/ARM.def"
43     LLD_KIND_STRING_END
44 };