1 //===- lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h ------------------===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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
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"
23 class X86_64TargetLayout : public TargetLayout<X86_64ELFType> {
25 X86_64TargetLayout(X86_64LinkingContext &context)
26 : TargetLayout(context) {}
28 void finalizeOutputSectionLayout() override {
29 sortOutputSectionByPriority(".init_array", ".init_array");
30 sortOutputSectionByPriority(".fini_array", ".fini_array");
34 class X86_64TargetHandler
35 : public DefaultTargetHandler<X86_64ELFType> {
37 X86_64TargetHandler(X86_64LinkingContext &context);
39 X86_64TargetLayout &getTargetLayout() override {
40 return *(_x86_64TargetLayout.get());
43 void registerRelocationNames(Registry ®istry) override;
45 const X86_64TargetRelocationHandler &getRelocationHandler() const override {
46 return *(_x86_64RelocationHandler.get());
49 std::unique_ptr<Reader> getObjReader() override {
50 return std::unique_ptr<Reader>(new X86_64ELFObjectReader(_context));
53 std::unique_ptr<Reader> getDSOReader() override {
54 return std::unique_ptr<Reader>(new X86_64ELFDSOReader(_context));
57 std::unique_ptr<Writer> getWriter() override;
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;
66 } // end namespace elf
67 } // end namespace lld