X86LDBackend.h revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
15460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===- X86LDBackend.h -----------------------------------------------------===//
25460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
35460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//                     The MCLinker Project
45460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
55460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// This file is distributed under the University of Illinois Open Source
65460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// License. See LICENSE.TXT for details.
75460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
85460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===//
95460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#ifndef X86_LDBACKEND_H
105460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#define X86_LDBACKEND_H
115460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
125460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#include "X86ELFDynamic.h"
135460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#include "X86GOT.h"
14affc150dc44fab1911775a49636d0ce85333b634Zonr Chang#include "X86GOTPLT.h"
155460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#include "X86PLT.h"
165460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#include <mcld/LD/LDSection.h>
175460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#include <mcld/Target/GNULDBackend.h>
185460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#include <mcld/Target/OutputRelocSection.h>
195460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaonamespace mcld {
215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass LinkerConfig;
2322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===//
255460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao/// X86GNULDBackend - linker backend of X86 target of GNU ELF format
265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao///
275460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass X86GNULDBackend : public GNULDBackend
285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao{
295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic:
305460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /** \enum ReservedEntryType
315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  \brief The reserved entry type of reserved space in ResolveInfo.
325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
335460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  This is used for sacnRelocation to record what kinds of entries are
345460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  reserved for this resolved symbol
355460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
365460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  In X86, there are three kinds of entries, GOT, PLT, and dynamic reloction.
375460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  GOT may needs a corresponding relocation to relocate itself, so we
385460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  separate GOT to two situations: GOT and GOTRel. Besides, for the same
395460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  symbol, there might be two kinds of entries reserved for different location.
405460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  For example, reference to the same symbol, one may use GOT and the other may
415460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  use dynamic relocation.
425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
435460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  bit:  3       2      1     0
445460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *   | PLT | GOTRel | GOT | Rel |
455460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
465460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  value    Name         - Description
475460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
485460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0000     None         - no reserved entry
495460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0001     ReserveRel   - reserve an dynamic relocation entry
505460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0010     ReserveGOT   - reserve an GOT entry
515460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0011     GOTandRel    - For different relocation, we've reserved GOT and
525460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          Rel for different location.
535460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0100     GOTRel       - reserve an GOT entry and the corresponding Dyncamic
545460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          relocation entry which relocate this GOT entry
555460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0101     GOTRelandRel - For different relocation, we've reserved GOTRel
565460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          and relocation entry for different location.
575460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  1000     ReservePLT   - reserve an PLT entry and the corresponding GOT,
585460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          Dynamic relocation entries
595460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  1001     PLTandRel    - For different relocation, we've reserved PLT and
605460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          Rel for different location.
615460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   */
625460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  enum ReservedEntryType {
635460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    None         = 0,
645460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    ReserveRel   = 1,
655460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    ReserveGOT   = 2,
665460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    GOTandRel    = 3,
675460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    GOTRel       = 4,
685460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    GOTRelandRel = 5,
695460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    ReservePLT   = 8,
705460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    PLTandRel    = 9
715460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  };
725460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
7322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaopublic:
7422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  X86GNULDBackend(const LinkerConfig& pConfig);
755460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
765460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ~X86GNULDBackend();
775460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
785460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  RelocationFactory* getRelocFactory();
795460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
805460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  uint32_t machine() const;
815460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
825460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  bool isLittleEndian() const
835460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  { return true; }
845460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
855460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86GOT& getGOT();
865460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
875460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const X86GOT& getGOT() const;
885460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
89affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  X86GOTPLT& getGOTPLT();
90affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
91affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  const X86GOTPLT& getGOTPLT() const;
92affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
935460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86PLT& getPLT();
945460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
955460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const X86PLT& getPLT() const;
965460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
9722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  GOT::Entry& getTLSModuleID();
9822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
995460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  unsigned int bitclass() const;
1005460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1015460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// preLayout - Backend can do any needed modification before layout
10222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  void doPreLayout(FragmentLinker& pLinker);
1035460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1045460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// postLayout -Backend can do any needed modification after layout
10522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  void doPostLayout(Module& pModule, FragmentLinker& pLinker);
1065460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1075460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// dynamic - the dynamic section of the target machine.
1085460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Use co-variant return type to return its own dynamic section.
1095460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86ELFDynamic& dynamic();
1105460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1115460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// dynamic - the dynamic section of the target machine.
1125460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Use co-variant return type to return its own dynamic section.
1135460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const X86ELFDynamic& dynamic() const;
1145460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1155460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// emitSectionData - write out the section data into the memory region.
1165460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// When writers get a LDSection whose kind is LDFileFormat::Target, writers
1175460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// call back target backend to emit the data.
1185460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ///
1195460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Backends handle the target-special tables (plt, gp,...) by themselves.
1205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Backend can put the data of the tables in MCSectionData directly
1215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ///  - LDSection.getSectionData can get the section data.
1225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Or, backend can put the data into special data structure
1235460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ///  - backend can maintain its own map<LDSection, table> to get the table
1245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// from given LDSection.
1255460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ///
1265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @param pSection - the given LDSection
127affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// @param pLayout - for comouting the size of fragment
1285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @param pRegion - the region to write out data
1295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @return the size of the table in the file.
13022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  uint64_t emitSectionData(const LDSection& pSection,
1315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                           MemoryRegion& pRegion) const;
1325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1335460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// OSABI - the value of e_ident[EI_OSABI]
1345460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// FIXME
1355460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  uint8_t OSABI() const
1365460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  { return llvm::ELF::ELFOSABI_NONE; }
1375460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1385460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// ABIVersion - the value of e_ident[EI_ABIVRESION]
1395460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// FIXME
1405460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  uint8_t ABIVersion() const
1415460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  { return 0x0; }
1425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1435460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// flags - the value of ElfXX_Ehdr::e_flags
1445460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// FIXME
1455460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  uint64_t flags() const
1465460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  { return 0x0; }
1475460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
148affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  uint64_t defaultTextSegmentAddr() const
149affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  { return 0x08048000; }
150affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
1515460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  // initRelocFactory - create and initialize RelocationFactory
15222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  bool initRelocFactory(const FragmentLinker& pLinker);
1535460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
15422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  void initTargetSections(Module& pModule, ObjectBuilder& pBuilder);
1555460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
15622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  void initTargetSymbols(FragmentLinker& pLinker);
1575460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1585460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// scanRelocation - determine the empty entries are needed or not and create
1595460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// the empty entries if needed.
1605460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// For X86, following entries are check to create:
1615460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// - GOT entry (for .got and .got.plt sections)
1625460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// - PLT entry (for .plt section)
1635460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// - dynamin relocation entries (for .rel.plt and .rel.dyn sections)
1645460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void scanRelocation(Relocation& pReloc,
16522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                      FragmentLinker& pLinker,
16622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                      Module& pModule,
167affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                      const LDSection& pSection);
1685460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1695460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  OutputRelocSection& getRelDyn();
1705460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1715460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const OutputRelocSection& getRelDyn() const;
1725460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1735460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  OutputRelocSection& getRelPLT();
1745460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1755460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const OutputRelocSection& getRelPLT() const;
1765460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1775460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// getTargetSectionOrder - compute the layout order of X86 target sections
17822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  unsigned int getTargetSectionOrder(const LDSection& pSectHdr) const;
1795460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
180affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// finalizeTargetSymbols - finalize the symbol value
18122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  bool finalizeTargetSymbols(FragmentLinker& pLinker);
1825460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1835460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoprivate:
1845460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void scanLocalReloc(Relocation& pReloc,
18522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                      FragmentLinker& pLinker,
18622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                      Module& pModule,
18722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                      const LDSection& pSection);
1885460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1895460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void scanGlobalReloc(Relocation& pReloc,
19022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                       FragmentLinker& pLinker,
19122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                       Module& pModule,
19222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                       const LDSection& pSection);
1935460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
194affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// addCopyReloc - add a copy relocation into .rel.dyn for pSym
195affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// @param pSym - A resolved copy symbol that defined in BSS section
196affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  void addCopyReloc(ResolveInfo& pSym);
1975460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
198affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// defineSymbolforCopyReloc - allocate a space in BSS section and
199affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// and force define the copy of pSym to BSS section
200affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// @return the output LDSymbol of the copy symbol
20122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  LDSymbol& defineSymbolforCopyReloc(FragmentLinker& pLinker,
202affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                                     const ResolveInfo& pSym);
2035460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
20422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  void defineGOTSymbol(FragmentLinker& pLinker);
20522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
20622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  /// getRelEntrySize - the size in BYTE of rel type relocation
20722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  size_t getRelEntrySize()
20822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  { return 8; }
20922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
21022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  /// getRelEntrySize - the size in BYTE of rela type relocation
21122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  size_t getRelaEntrySize()
21222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  { return 12; }
2135460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
21422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  /// doCreateProgramHdrs - backend can implement this function to create the
21522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  /// target-dependent segments
21622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  virtual void doCreateProgramHdrs(Module& pModule,
21722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                                   const FragmentLinker& pLinker);
2185460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2195460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoprivate:
2205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  RelocationFactory* m_pRelocFactory;
2215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86GOT* m_pGOT;
2225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86PLT* m_pPLT;
223affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  X86GOTPLT* m_pGOTPLT;
2245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// m_RelDyn - dynamic relocation table of .rel.dyn
2255460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  OutputRelocSection* m_pRelDyn;
2265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// m_RelPLT - dynamic relocation table of .rel.plt
2275460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  OutputRelocSection* m_pRelPLT;
2285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86ELFDynamic* m_pDynamic;
2305460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  LDSymbol* m_pGOTSymbol;
2315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao};
2325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2335460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===//
2345460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao/// X86MachOLDBackend - linker backend of X86 target of MachO format
2355460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao///
2365460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao/**
2375460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass X86MachOLDBackend : public DarwinX86LDBackend
2385460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao{
2395460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic:
2405460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86MachOLDBackend();
2415460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ~X86MachOLDBackend();
2425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2435460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoprivate:
2445460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  MCMachOTargetArchiveReader *createTargetArchiveReader() const;
2455460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  MCMachOTargetObjectReader *createTargetObjectReader() const;
2465460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  MCMachOTargetObjectWriter *createTargetObjectWriter() const;
2475460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2485460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao};
2495460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao**/
2505460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao} // namespace of mcld
2515460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2525460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#endif
253affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
254