summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp
blob: 98ada6050ce622616d309d2a14b0834b8b10fa0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//===--------- lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp --------------===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "Atoms.h"
#include "ARMExecutableWriter.h"
#include "ARMTargetHandler.h"
#include "ARMLinkingContext.h"

using namespace lld;
using namespace elf;

ARMTargetHandler::ARMTargetHandler(ARMLinkingContext &context)
    : _context(context), _armTargetLayout(
          new ARMTargetLayout<ARMELFType>(context)),
      _armRelocationHandler(new ARMTargetRelocationHandler(
          *_armTargetLayout.get())) {}

void ARMTargetHandler::registerRelocationNames(Registry &registry) {
  registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::ARM,
                        kindStrings);
}

std::unique_ptr<Writer> ARMTargetHandler::getWriter() {
  switch (this->_context.getOutputELFType()) {
  case llvm::ELF::ET_EXEC:
    return llvm::make_unique<ARMExecutableWriter<ARMELFType>>(
        _context, *_armTargetLayout.get());
  default:
    llvm_unreachable("unsupported output type");
  }
}

#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),

const Registry::KindStrings ARMTargetHandler::kindStrings[] = {
#include "llvm/Support/ELFRelocs/ARM.def"
    LLD_KIND_STRING_END
};
OpenPOWER on IntegriCloud