summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h
blob: fe818d1ef21cc742d2fea98fe350b9a2d28c5713 (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
//===- lld/ReaderWriter/ELF/Mips/MipsRelocationHandler.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_MIPS_MIPS_RELOCATION_HANDLER_H
#define LLD_READER_WRITER_ELF_MIPS_MIPS_RELOCATION_HANDLER_H

#include "MipsLinkingContext.h"

namespace lld {
namespace elf {

class MipsTargetHandler;

class MipsTargetRelocationHandler final
    : public TargetRelocationHandler<Mips32ElELFType> {
public:
  MipsTargetRelocationHandler(MipsLinkingContext &context,
                              MipsTargetLayout<Mips32ElELFType> &layout)
      : _mipsLinkingContext(context), _mipsTargetLayout(layout) {}

  ~MipsTargetRelocationHandler();

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

private:
  typedef std::vector<const Reference *> PairedRelocationsT;
  typedef std::unordered_map<const lld::AtomLayout *, PairedRelocationsT>
  PairedRelocationMapT;

  mutable PairedRelocationMapT _pairedRelocations;

  void savePairedRelocation(const lld::AtomLayout &atom,
                            const Reference &ref) const;
  void applyPairedRelocations(ELFWriter &writer, llvm::FileOutputBuffer &buf,
                              const lld::AtomLayout &atom, int64_t gpAddr,
                              int64_t loAddend) const;

  MipsLinkingContext &_mipsLinkingContext LLVM_ATTRIBUTE_UNUSED;
  MipsTargetLayout<Mips32ElELFType> &_mipsTargetLayout;
};

} // elf
} // lld

#endif
OpenPOWER on IntegriCloud