15460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===- MipsLDBackend.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//===----------------------------------------------------------------------===// 9551ae4ebd3e9d137ea668fb83ae4a55b8cfba451Stephen Hines#ifndef TARGET_MIPS_MIPSLDBACKEND_H 10551ae4ebd3e9d137ea668fb83ae4a55b8cfba451Stephen Hines#define TARGET_MIPS_MIPSLDBACKEND_H 1122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#include <mcld/Target/GNULDBackend.h> 125460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#include "MipsELFDynamic.h" 135460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#include "MipsGOT.h" 1487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#include "MipsGOTPLT.h" 1587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#include "MipsPLT.h" 165460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 175460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaonamespace mcld { 185460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 1922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass LinkerConfig; 205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass OutputRelocSection; 215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass SectionMap; 2222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass MemoryArea; 23d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liaoclass MipsGNUInfo; 245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 2587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines/** \class MipsGNULDBackend 2687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines * \brief Base linker backend of Mips target of GNU ELF format. 2787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines */ 285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoclass MipsGNULDBackend : public GNULDBackend 295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao{ 305460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic: 31f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines typedef std::vector<LDSymbol*> SymbolListType; 325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 335460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic: 34d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao MipsGNULDBackend(const LinkerConfig& pConfig, MipsGNUInfo* pInfo); 355460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao ~MipsGNULDBackend(); 365460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 3787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool needsLA25Stub(Relocation::Type pType, const mcld::ResolveInfo* pSym); 3887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 3987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines void addNonPICBranchSym(ResolveInfo* rsym); 4087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool hasNonPICBranch(const ResolveInfo* rsym) const; 4187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaopublic: 435460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// initTargetSections - initialize target dependent sections in output 4422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao void initTargetSections(Module& pModule, ObjectBuilder& pBuilder); 455460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 465460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// initTargetSymbols - initialize target dependent symbols in output. 476f75755c9204b1d8817ae5a65a2f7e5af0ec3f70Stephen Hines void initTargetSymbols(IRBuilder& pBuilder, Module& pModule); 485460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 49d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao /// getRelocator - return relocator. 50a790f0a8f3175183bea088389b3e4ae41813e192Stephen Hines const Relocator* getRelocator() const; 51d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao Relocator* getRelocator(); 525460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 535460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// preLayout - Backend can do any needed modification before layout 546f75755c9204b1d8817ae5a65a2f7e5af0ec3f70Stephen Hines void doPreLayout(IRBuilder& pBuilder); 555460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 566f75755c9204b1d8817ae5a65a2f7e5af0ec3f70Stephen Hines /// postLayout - Backend can do any needed modification after layout 576f75755c9204b1d8817ae5a65a2f7e5af0ec3f70Stephen Hines void doPostLayout(Module& pModule, IRBuilder& pBuilder); 585460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 595460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// dynamic - the dynamic section of the target machine. 605460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// Use co-variant return type to return its own dynamic section. 615460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao MipsELFDynamic& dynamic(); 625460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 635460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// dynamic - the dynamic section of the target machine. 645460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// Use co-variant return type to return its own dynamic section. 655460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao const MipsELFDynamic& dynamic() const; 665460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 675460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// emitSectionData - write out the section data into the memory region. 685460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// When writers get a LDSection whose kind is LDFileFormat::Target, writers 695460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// call back target backend to emit the data. 705460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// 715460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// Backends handle the target-special tables (plt, gp,...) by themselves. 72cedee4b38f4786845183be7f5916dd520a170ae0Shih-wei Liao /// Backend can put the data of the tables in SectionData directly 735460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// - LDSection.getSectionData can get the section data. 745460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// Or, backend can put the data into special data structure 755460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// - backend can maintain its own map<LDSection, table> to get the table 765460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// from given LDSection. 775460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// 785460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// @param pSection - the given LDSection 795460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// @param pRegion - the region to write out data 805460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// @return the size of the table in the file. 8122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao uint64_t emitSectionData(const LDSection& pSection, 825460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao MemoryRegion& pRegion) const; 835460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 84f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines /// hasEntryInStrTab - symbol has an entry in a .strtab 85f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines bool hasEntryInStrTab(const LDSymbol& pSym) const; 8622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 87f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines /// orderSymbolTable - order symbol table before emitting 88f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines void orderSymbolTable(Module& pModule); 895460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 9087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// readSection - read a target dependent section. 9187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool readSection(Input& pInput, SectionData& pSD); 9287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 935460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao MipsGOT& getGOT(); 945460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao const MipsGOT& getGOT() const; 955460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 9687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines MipsPLT& getPLT(); 9787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines const MipsPLT& getPLT() const; 9887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 9987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines MipsGOTPLT& getGOTPLT(); 10087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines const MipsGOTPLT& getGOTPLT() const; 10187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 10287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines OutputRelocSection& getRelPLT(); 10387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines const OutputRelocSection& getRelPLT() const; 10487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 1055460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao OutputRelocSection& getRelDyn(); 1065460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao const OutputRelocSection& getRelDyn() const; 1075460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 10887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines LDSymbol* getGOTSymbol() { return m_pGOTSymbol; } 10987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines const LDSymbol* getGOTSymbol() const { return m_pGOTSymbol; } 110f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines 111f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines LDSymbol* getGpDispSymbol() { return m_pGpDispSymbol; } 112f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines const LDSymbol* getGpDispSymbol() const { return m_pGpDispSymbol; } 113f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines 114f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines SymbolListType& getGlobalGOTSyms() { return m_GlobalGOTSyms; } 115f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines const SymbolListType& getGlobalGOTSyms() const { return m_GlobalGOTSyms; } 116f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines 1175460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// getTargetSectionOrder - compute the layout order of ARM target sections 11822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao unsigned int getTargetSectionOrder(const LDSection& pSectHdr) const; 1195460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 1205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// finalizeSymbol - finalize the symbol value 1216f75755c9204b1d8817ae5a65a2f7e5af0ec3f70Stephen Hines bool finalizeTargetSymbols(); 1225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 1235460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// allocateCommonSymbols - allocate common symbols in the corresponding 1245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao /// sections. 12522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao bool allocateCommonSymbols(Module& pModule); 1265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 12787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// getGP0 - the gp value used to create the relocatable objects 12887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// in the specified input. 12987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint64_t getGP0(const Input& pInput) const; 13087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 1315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoprivate: 1326f75755c9204b1d8817ae5a65a2f7e5af0ec3f70Stephen Hines void defineGOTSymbol(IRBuilder& pBuilder); 13387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines void defineGOTPLTSymbol(IRBuilder& pBuilder); 13487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 13587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool relaxRelocation(IRBuilder& pBuilder, Relocation& pRel); 13622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 13722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao /// emitSymbol32 - emit an ELF32 symbol, override parent's function 13822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao void emitSymbol32(llvm::ELF::Elf32_Sym& pSym32, 13922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao LDSymbol& pSymbol, 14022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao char* pStrtab, 14122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao size_t pStrtabsize, 14222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao size_t pSymtabIdx); 14322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao 14422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao /// doCreateProgramHdrs - backend can implement this function to create the 14522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao /// target-dependent segments 1466f75755c9204b1d8817ae5a65a2f7e5af0ec3f70Stephen Hines void doCreateProgramHdrs(Module& pModule); 1475460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 14887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// mayRelax - Backends should override this function if they need relaxation 14987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool mayRelax() { return true; } 15087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 15187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// doRelax - Backend can orevride this function to add its relaxation 15287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// implementation. Return true if the output (e.g., .text) is "relaxed" 15387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// (i.e. layout is changed), and set pFinished to true if everything is fit, 15487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// otherwise set it to false. 15587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool doRelax(Module& pModule, IRBuilder& pBuilder, bool& pFinished); 15687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 15787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// initTargetStubs 15887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool initTargetStubs(); 15987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 16087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// readRelocation - read ELF32_Rel entry 16187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool readRelocation(const llvm::ELF::Elf32_Rel& pRel, 16287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Relocation::Type& pType, 16387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t& pSymIdx, 16487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t& pOffset) const; 16587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 16687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// readRelocation - read ELF32_Rela entry 16787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool readRelocation(const llvm::ELF::Elf32_Rela& pRel, 16887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Relocation::Type& pType, 16987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t& pSymIdx, 17087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t& pOffset, 17187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines int32_t& pAddend) const; 17287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 17387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// readRelocation - read ELF64_Rel entry 17487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool readRelocation(const llvm::ELF::Elf64_Rel& pRel, 17587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Relocation::Type& pType, 17687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t& pSymIdx, 17787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint64_t& pOffset) const; 17887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 17987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// readRel - read ELF64_Rela entry 18087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool readRelocation(const llvm::ELF::Elf64_Rela& pRel, 18187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Relocation::Type& pType, 18287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t& pSymIdx, 18387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint64_t& pOffset, 18487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines int64_t& pAddend) const; 18587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 18687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// emitRelocation - write data to the ELF32_Rel entry 18787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines void emitRelocation(llvm::ELF::Elf32_Rel& pRel, 18887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Relocation::Type pType, 18987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t pSymIdx, 19087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t pOffset) const; 19187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 19287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// emitRelocation - write data to the ELF32_Rela entry 19387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines void emitRelocation(llvm::ELF::Elf32_Rela& pRel, 19487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Relocation::Type pType, 19587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t pSymIdx, 19687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t pOffset, 19787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines int32_t pAddend) const; 19887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 19987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// emitRelocation - write data to the ELF64_Rel entry 20087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines void emitRelocation(llvm::ELF::Elf64_Rel& pRel, 20187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Relocation::Type pType, 20287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t pSymIdx, 20387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint64_t pOffset) const; 20487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 20587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines /// emitRelocation - write data to the ELF64_Rela entry 20687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines void emitRelocation(llvm::ELF::Elf64_Rela& pRel, 20787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Relocation::Type pType, 20887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint32_t pSymIdx, 20987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines uint64_t pOffset, 21087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines int64_t pAddend) const; 21187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 2125460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liaoprivate: 21387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines typedef llvm::DenseSet<const ResolveInfo*> ResolveInfoSetType; 21487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines typedef llvm::DenseMap<const Input*, llvm::ELF::Elf64_Addr> GP0MapType; 2155460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 21687f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesprotected: 21787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Relocator* m_pRelocator; 2185460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao MipsGOT* m_pGOT; // .got 21987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines MipsPLT* m_pPLT; // .plt 22087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines MipsGOTPLT* m_pGOTPLT; // .got.plt 22187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 22287f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesprivate: 22387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines MipsGNUInfo& m_pInfo; 22487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 22587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines OutputRelocSection* m_pRelPlt; // .rel.plt 2265460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao OutputRelocSection* m_pRelDyn; // .rel.dyn 2275460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 2285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao MipsELFDynamic* m_pDynamic; 2295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao LDSymbol* m_pGOTSymbol; 23087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines LDSymbol* m_pPLTSymbol; 2315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao LDSymbol* m_pGpDispSymbol; 2325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 233f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines SymbolListType m_GlobalGOTSyms; 23487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines ResolveInfoSetType m_HasNonPICBranchSyms; 23587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines GP0MapType m_GP0Map; 23687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines}; 23787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 23887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines/** \class Mips32GNULDBackend 23987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines * \brief Base linker backend of Mips 32-bit target of GNU ELF format. 24087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines */ 24187f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesclass Mips32GNULDBackend : public MipsGNULDBackend 24287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines{ 24387f34658dec9097d987d254a990ea7f311bfc95fStephen Hinespublic: 24487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Mips32GNULDBackend(const LinkerConfig& pConfig, MipsGNUInfo* pInfo); 24587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 24687f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesprivate: 24787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines // MipsGNULDBackend 24887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 24987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool initRelocator(); 25087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines void initTargetSections(Module& pModule, ObjectBuilder& pBuilder); 25187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines size_t getRelEntrySize(); 25287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines size_t getRelaEntrySize(); 25387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines}; 25487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 25587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines/** \class Mips64GNULDBackend 25687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines * \brief Base linker backend of Mips 64-bit target of GNU ELF format. 25787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines */ 25887f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesclass Mips64GNULDBackend : public MipsGNULDBackend 25987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines{ 26087f34658dec9097d987d254a990ea7f311bfc95fStephen Hinespublic: 26187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines Mips64GNULDBackend(const LinkerConfig& pConfig, MipsGNUInfo* pInfo); 26287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 26387f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesprivate: 26487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines // MipsGNULDBackend 26587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines 26687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines bool initRelocator(); 26787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines void initTargetSections(Module& pModule, ObjectBuilder& pBuilder); 26887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines size_t getRelEntrySize(); 26987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines size_t getRelaEntrySize(); 2705460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao}; 2715460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 2725460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao} // namespace of mcld 2735460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 2745460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao#endif 275