]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / lib / ReaderWriter / ELF / Mips / MipsLinkingContext.h
1 //===- lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h ---------------------===//
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 #ifndef LLD_READER_WRITER_ELF_MIPS_MIPS_LINKING_CONTEXT_H
10 #define LLD_READER_WRITER_ELF_MIPS_MIPS_LINKING_CONTEXT_H
11
12 #include "MipsELFFlagsMerger.h"
13 #include "lld/ReaderWriter/ELFLinkingContext.h"
14
15 namespace lld {
16 namespace elf {
17
18 /// \brief Mips internal references.
19 enum {
20   /// \brief Do nothing but mark GOT entry as a global one.
21   LLD_R_MIPS_GLOBAL_GOT = 1024,
22   /// \brief Apply high 16 bits of symbol + addend.
23   LLD_R_MIPS_32_HI16 = 1025,
24   /// \brief The same as R_MIPS_26 but for global symbols.
25   LLD_R_MIPS_GLOBAL_26 = 1026,
26   /// \brief Setup hi 16 bits using the symbol this reference refers to.
27   LLD_R_MIPS_HI16 = 1027,
28   /// \brief Setup low 16 bits using the symbol this reference refers to.
29   LLD_R_MIPS_LO16 = 1028,
30   /// \brief Represents a reference between PLT and dynamic symbol.
31   LLD_R_MIPS_STO_PLT = 1029,
32   /// \brief The same as R_MICROMIPS_26_S1 but for global symbols.
33   LLD_R_MICROMIPS_GLOBAL_26_S1 = 1030,
34   /// \brief Apply high 32+16 bits of symbol + addend.
35   LLD_R_MIPS_64_HI16 = 1031,
36 };
37
38 typedef llvm::object::ELFType<llvm::support::little, 2, false> Mips32ELType;
39 typedef llvm::object::ELFType<llvm::support::little, 2, true> Mips64ELType;
40 typedef llvm::object::ELFType<llvm::support::big, 2, false> Mips32BEType;
41 typedef llvm::object::ELFType<llvm::support::big, 2, true> Mips64BEType;
42
43 class MipsLinkingContext final : public ELFLinkingContext {
44 public:
45   static std::unique_ptr<ELFLinkingContext> create(llvm::Triple);
46   MipsLinkingContext(llvm::Triple triple);
47
48   uint32_t getMergedELFFlags() const;
49   MipsELFFlagsMerger &getELFFlagsMerger();
50
51   // ELFLinkingContext
52   uint64_t getBaseAddress() const override;
53   StringRef entrySymbolName() const override;
54   StringRef getDefaultInterpreter() const override;
55   void addPasses(PassManager &pm) override;
56   bool isRelaOutputFormat() const override { return false; }
57   bool isDynamicRelocation(const Reference &r) const override;
58   bool isCopyRelocation(const Reference &r) const override;
59   bool isPLTRelocation(const Reference &r) const override;
60
61 private:
62   MipsELFFlagsMerger _flagsMerger;
63 };
64
65 } // elf
66 } // lld
67
68 #endif