summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h
blob: 4c8b8c5812422ef05ea7fc18983bc1113284d14c (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//===- lib/ReaderWriter/ELF/PPC/PPCTargetHandler.h ------------------------===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLD_READER_WRITER_ELF_PPC_PPC_TARGET_HANDLER_H
#define LLD_READER_WRITER_ELF_PPC_PPC_TARGET_HANDLER_H

#include "DefaultTargetHandler.h"
#include "TargetLayout.h"

namespace lld {
namespace elf {
typedef llvm::object::ELFType<llvm::support::big, 2, false> PPCELFType;
class PPCLinkingContext;

template <class ELFT> class PPCTargetLayout : public TargetLayout<ELFT> {
public:
  PPCTargetLayout(PPCLinkingContext &context) : TargetLayout<ELFT>(context) {}
};

class PPCTargetRelocationHandler final
    : public TargetRelocationHandler<PPCELFType> {
public:
  PPCTargetRelocationHandler(PPCLinkingContext &context,
                             PPCTargetLayout<PPCELFType> &layout)
      : _ppcContext(context), _ppcTargetLayout(layout) {}

  virtual std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
                                          const lld::AtomLayout &,
                                          const Reference &) const override;

protected:
  PPCLinkingContext &_ppcContext;
  PPCTargetLayout<PPCELFType> &_ppcTargetLayout;
};

class PPCTargetHandler final
    : public DefaultTargetHandler<PPCELFType> {
public:
  PPCTargetHandler(PPCLinkingContext &context);

  PPCTargetLayout<PPCELFType> &getTargetLayout() override {
    return *(_ppcTargetLayout.get());
  }

  void registerRelocationNames(Registry &registry) override;

  const PPCTargetRelocationHandler &getRelocationHandler() const override {
    return *(_ppcRelocationHandler.get());
  }

  std::unique_ptr<Writer> getWriter() override;

private:
  static const Registry::KindStrings kindStrings[];
  PPCLinkingContext &_ppcLinkingContext;
  std::unique_ptr<PPCTargetLayout<PPCELFType>> _ppcTargetLayout;
  std::unique_ptr<PPCTargetRelocationHandler> _ppcRelocationHandler;
};
} // end namespace elf
} // end namespace lld

#endif
OpenPOWER on IntegriCloud