]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / lib / ReaderWriter / ELF / X86_64 / X86_64TargetHandler.h
1 //===- lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.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
10 #ifndef LLD_READER_WRITER_ELF_X86_64_X86_64_TARGET_HANDLER_H
11 #define LLD_READER_WRITER_ELF_X86_64_X86_64_TARGET_HANDLER_H
12
13 #include "DefaultTargetHandler.h"
14 #include "TargetLayout.h"
15 #include "X86_64ELFFile.h"
16 #include "X86_64ELFReader.h"
17 #include "X86_64LinkingContext.h"
18 #include "X86_64RelocationHandler.h"
19 #include "lld/Core/Simple.h"
20
21 namespace lld {
22 namespace elf {
23 class X86_64TargetLayout : public TargetLayout<X86_64ELFType> {
24 public:
25   X86_64TargetLayout(X86_64LinkingContext &context)
26       : TargetLayout(context) {}
27
28   void finalizeOutputSectionLayout() override {
29     sortOutputSectionByPriority(".init_array", ".init_array");
30     sortOutputSectionByPriority(".fini_array", ".fini_array");
31   }
32 };
33
34 class X86_64TargetHandler
35     : public DefaultTargetHandler<X86_64ELFType> {
36 public:
37   X86_64TargetHandler(X86_64LinkingContext &context);
38
39   X86_64TargetLayout &getTargetLayout() override {
40     return *(_x86_64TargetLayout.get());
41   }
42
43   void registerRelocationNames(Registry &registry) override;
44
45   const X86_64TargetRelocationHandler &getRelocationHandler() const override {
46     return *(_x86_64RelocationHandler.get());
47   }
48
49   std::unique_ptr<Reader> getObjReader() override {
50     return std::unique_ptr<Reader>(new X86_64ELFObjectReader(_context));
51   }
52
53   std::unique_ptr<Reader> getDSOReader() override {
54     return std::unique_ptr<Reader>(new X86_64ELFDSOReader(_context));
55   }
56
57   std::unique_ptr<Writer> getWriter() override;
58
59 protected:
60   static const Registry::KindStrings kindStrings[];
61   X86_64LinkingContext &_context;
62   std::unique_ptr<X86_64TargetLayout> _x86_64TargetLayout;
63   std::unique_ptr<X86_64TargetRelocationHandler> _x86_64RelocationHandler;
64 };
65
66 } // end namespace elf
67 } // end namespace lld
68
69 #endif