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
225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===//
235460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao/// X86GNULDBackend - linker backend of X86 target of GNU ELF format
245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao///
255460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass X86GNULDBackend : public GNULDBackend
265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao{
275460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic:
285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /** \enum ReservedEntryType
295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  \brief The reserved entry type of reserved space in ResolveInfo.
305460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  This is used for sacnRelocation to record what kinds of entries are
325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  reserved for this resolved symbol
335460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
345460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  In X86, there are three kinds of entries, GOT, PLT, and dynamic reloction.
355460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  GOT may needs a corresponding relocation to relocate itself, so we
365460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  separate GOT to two situations: GOT and GOTRel. Besides, for the same
375460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  symbol, there might be two kinds of entries reserved for different location.
385460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  For example, reference to the same symbol, one may use GOT and the other may
395460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  use dynamic relocation.
405460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
415460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  bit:  3       2      1     0
425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *   | PLT | GOTRel | GOT | Rel |
435460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
445460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  value    Name         - Description
455460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *
465460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0000     None         - no reserved entry
475460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0001     ReserveRel   - reserve an dynamic relocation entry
485460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0010     ReserveGOT   - reserve an GOT entry
495460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0011     GOTandRel    - For different relocation, we've reserved GOT and
505460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          Rel for different location.
515460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0100     GOTRel       - reserve an GOT entry and the corresponding Dyncamic
525460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          relocation entry which relocate this GOT entry
535460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  0101     GOTRelandRel - For different relocation, we've reserved GOTRel
545460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          and relocation entry for different location.
555460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  1000     ReservePLT   - reserve an PLT entry and the corresponding GOT,
565460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          Dynamic relocation entries
575460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *  1001     PLTandRel    - For different relocation, we've reserved PLT and
585460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   *                          Rel for different location.
595460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao   */
605460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  enum ReservedEntryType {
615460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    None         = 0,
625460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    ReserveRel   = 1,
635460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    ReserveGOT   = 2,
645460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    GOTandRel    = 3,
655460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    GOTRel       = 4,
665460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    GOTRelandRel = 5,
675460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    ReservePLT   = 8,
685460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao    PLTandRel    = 9
695460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  };
705460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
715460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86GNULDBackend();
725460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
735460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ~X86GNULDBackend();
745460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
755460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  RelocationFactory* getRelocFactory();
765460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
775460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  uint32_t machine() const;
785460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
795460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  bool isLittleEndian() const
805460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  { return true; }
815460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
825460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86GOT& getGOT();
835460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
845460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const X86GOT& getGOT() const;
855460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
86affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  X86GOTPLT& getGOTPLT();
87affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
88affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  const X86GOTPLT& getGOTPLT() const;
89affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
905460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86PLT& getPLT();
915460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
925460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const X86PLT& getPLT() const;
935460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
945460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  unsigned int bitclass() const;
955460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
965460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// preLayout - Backend can do any needed modification before layout
975460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void doPreLayout(const Output& pOutput,
985460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                   const MCLDInfo& pInfo,
995460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                   MCLinker& pLinker);
1005460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1015460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// postLayout -Backend can do any needed modification after layout
1025460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void doPostLayout(const Output& pOutput,
1035460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                    const MCLDInfo& pInfo,
1045460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                    MCLinker& pLinker);
1055460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1065460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// dynamic - the dynamic section of the target machine.
1075460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Use co-variant return type to return its own dynamic section.
1085460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86ELFDynamic& dynamic();
1095460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1105460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// dynamic - the dynamic section of the target machine.
1115460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Use co-variant return type to return its own dynamic section.
1125460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const X86ELFDynamic& dynamic() const;
1135460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1145460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// emitSectionData - write out the section data into the memory region.
1155460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// When writers get a LDSection whose kind is LDFileFormat::Target, writers
1165460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// call back target backend to emit the data.
1175460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ///
1185460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Backends handle the target-special tables (plt, gp,...) by themselves.
1195460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Backend can put the data of the tables in MCSectionData directly
1205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ///  - LDSection.getSectionData can get the section data.
1215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// Or, backend can put the data into special data structure
1225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ///  - backend can maintain its own map<LDSection, table> to get the table
1235460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// from given LDSection.
1245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ///
1255460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @param pOutput - the output file
1265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @param pSection - the given LDSection
1275460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @param pInfo - all options in the command line.
128affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// @param pLayout - for comouting the size of fragment
1295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @param pRegion - the region to write out data
1305460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @return the size of the table in the file.
1315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  uint64_t emitSectionData(const Output& pOutput,
1325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                           const LDSection& pSection,
1335460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                           const MCLDInfo& pInfo,
134affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                           const Layout& pLayout,
1355460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                           MemoryRegion& pRegion) const;
1365460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1375460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// OSABI - the value of e_ident[EI_OSABI]
1385460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// FIXME
1395460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  uint8_t OSABI() const
1405460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  { return llvm::ELF::ELFOSABI_NONE; }
1415460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// ABIVersion - the value of e_ident[EI_ABIVRESION]
1435460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// FIXME
1445460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  uint8_t ABIVersion() const
1455460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  { return 0x0; }
1465460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1475460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// flags - the value of ElfXX_Ehdr::e_flags
1485460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// FIXME
1495460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  uint64_t flags() const
1505460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  { return 0x0; }
1515460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
152affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  uint64_t defaultTextSegmentAddr() const
153affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  { return 0x08048000; }
154affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
1555460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// initTargetSectionMap - initialize target dependent section mapping
1565460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  bool initTargetSectionMap(SectionMap& pSectionMap);
1575460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1585460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  // initRelocFactory - create and initialize RelocationFactory
1595460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  bool initRelocFactory(const MCLinker& pLinker);
1605460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1615460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void initTargetSections(MCLinker& pLinker);
1625460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
163affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  void initTargetSymbols(MCLinker& pLinker, const Output& pOutput);
1645460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1655460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// scanRelocation - determine the empty entries are needed or not and create
1665460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// the empty entries if needed.
1675460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// For X86, following entries are check to create:
1685460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// - GOT entry (for .got and .got.plt sections)
1695460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// - PLT entry (for .plt section)
1705460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// - dynamin relocation entries (for .rel.plt and .rel.dyn sections)
1715460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void scanRelocation(Relocation& pReloc,
1725460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                      const LDSymbol& pInputSym,
1735460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                      MCLinker& pLinker,
1745460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                      const MCLDInfo& pLDInfo,
175affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                      const Output& pOutput,
176affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                      const LDSection& pSection);
1775460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1785460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  OutputRelocSection& getRelDyn();
1795460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1805460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const OutputRelocSection& getRelDyn() const;
1815460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1825460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  OutputRelocSection& getRelPLT();
1835460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1845460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  const OutputRelocSection& getRelPLT() const;
1855460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1865460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// getTargetSectionOrder - compute the layout order of X86 target sections
1875460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  unsigned int getTargetSectionOrder(const Output& pOutput,
188affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                                     const LDSection& pSectHdr,
189affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                                     const MCLDInfo& pInfo) const;
1905460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
191affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// finalizeTargetSymbols - finalize the symbol value
192affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  bool finalizeTargetSymbols(MCLinker& pLinker, const Output& pOutput);
1935460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1945460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoprivate:
1955460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void scanLocalReloc(Relocation& pReloc,
1965460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                      const LDSymbol& pInputSym,
1975460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                      MCLinker& pLinker,
1985460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                      const MCLDInfo& pLDInfo,
1995460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                      const Output& pOutput);
2005460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2015460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void scanGlobalReloc(Relocation& pReloc,
2025460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                       const LDSymbol& pInputSym,
2035460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                       MCLinker& pLinker,
2045460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                       const MCLDInfo& pLDInfo,
2055460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                       const Output& pOutput);
2065460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
207affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// addCopyReloc - add a copy relocation into .rel.dyn for pSym
208affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// @param pSym - A resolved copy symbol that defined in BSS section
209affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  void addCopyReloc(ResolveInfo& pSym);
2105460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
211affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// defineSymbolforCopyReloc - allocate a space in BSS section and
212affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// and force define the copy of pSym to BSS section
213affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  /// @return the output LDSymbol of the copy symbol
214affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  LDSymbol& defineSymbolforCopyReloc(MCLinker& pLinker,
215affc150dc44fab1911775a49636d0ce85333b634Zonr Chang                                     const ResolveInfo& pSym);
2165460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2175460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void updateAddend(Relocation& pReloc,
2185460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                    const LDSymbol& pInputSym,
2195460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao                    const Layout& pLayout) const;
2205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void createX86GOT(MCLinker& pLinker, const Output& pOutput);
222affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  void createX86GOTPLT(MCLinker& pLinker, const Output& pOutput);
2235460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void createX86PLTandRelPLT(MCLinker& pLinker, const Output& pOutput);
2245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void createX86RelDyn(MCLinker& pLinker, const Output& pOutput);
2255460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoprivate:
2275460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  RelocationFactory* m_pRelocFactory;
2285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86GOT* m_pGOT;
2295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86PLT* m_pPLT;
230affc150dc44fab1911775a49636d0ce85333b634Zonr Chang  X86GOTPLT* m_pGOTPLT;
2315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// m_RelDyn - dynamic relocation table of .rel.dyn
2325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  OutputRelocSection* m_pRelDyn;
2335460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// m_RelPLT - dynamic relocation table of .rel.plt
2345460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  OutputRelocSection* m_pRelPLT;
2355460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2365460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86ELFDynamic* m_pDynamic;
2375460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  LDSymbol* m_pGOTSymbol;
2385460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao};
2395460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2405460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===//
2415460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao/// X86MachOLDBackend - linker backend of X86 target of MachO format
2425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao///
2435460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao/**
2445460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass X86MachOLDBackend : public DarwinX86LDBackend
2455460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao{
2465460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic:
2475460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  X86MachOLDBackend();
2485460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  ~X86MachOLDBackend();
2495460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2505460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoprivate:
2515460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  MCMachOTargetArchiveReader *createTargetArchiveReader() const;
2525460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  MCMachOTargetObjectReader *createTargetObjectReader() const;
2535460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  MCMachOTargetObjectWriter *createTargetObjectWriter() const;
2545460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2555460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao};
2565460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao**/
2575460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao} // namespace of mcld
2585460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
2595460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#endif
260affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
261