LinkerScript.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
1//===- LinkerScript.h -----------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_LINKERSCRIPT_H 10#define MCLD_LINKERSCRIPT_H 11#ifdef ENABLE_UNITTEST 12#include <gtest.h> 13#endif 14#include <string> 15#include <vector> 16#include <llvm/ADT/StringRef.h> 17#include <mcld/ADT/StringEntry.h> 18#include <mcld/ADT/StringHash.h> 19#include <mcld/ADT/HashTable.h> 20#include <mcld/Object/SectionMap.h> 21#include <mcld/MC/SearchDirs.h> 22#include <mcld/Script/Assignment.h> 23#include <mcld/Script/AssertCmd.h> 24 25namespace mcld { 26 27class LDSymbol; 28 29/** \class LinkerScript 30 * 31 */ 32class LinkerScript 33{ 34public: 35 typedef HashTable<StringEntry<llvm::StringRef>, 36 hash::StringHash<hash::DJB>, 37 StringEntryFactory<llvm::StringRef> > SymbolRenameMap; 38 39 typedef HashTable<StringEntry<uint64_t>, 40 hash::StringHash<hash::DJB>, 41 StringEntryFactory<uint64_t> > AddressMap; 42 43 typedef std::vector<std::pair<LDSymbol*, Assignment> > Assignments; 44 45 typedef std::vector<AssertCmd> Assertions; 46 47public: 48 LinkerScript(); 49 50 ~LinkerScript(); 51 52 const SymbolRenameMap& renameMap() const { return m_SymbolRenames; } 53 SymbolRenameMap& renameMap() { return m_SymbolRenames; } 54 55 const AddressMap& addressMap() const { return m_AddressMap; } 56 AddressMap& addressMap() { return m_AddressMap; } 57 58 const SectionMap& sectionMap() const { return m_SectionMap; } 59 SectionMap& sectionMap() { return m_SectionMap; } 60 61 const Assignments& assignments() const { return m_Assignments; } 62 Assignments& assignments() { return m_Assignments; } 63 64 const Assertions& assertions() const { return m_Assertions; } 65 Assertions& assertions() { return m_Assertions; } 66 67 /// search directory 68 const SearchDirs& directories() const { return m_SearchDirs; } 69 SearchDirs& directories() { return m_SearchDirs; } 70 71 /// sysroot 72 const sys::fs::Path& sysroot() const; 73 74 void setSysroot(const sys::fs::Path &pPath); 75 76 bool hasSysroot() const; 77 78 /// entry point 79 const std::string& entry() const; 80 81 void setEntry(const std::string& pEntry); 82 83 bool hasEntry() const; 84 85 /// output filename 86 const std::string& outputFile() const; 87 88 void setOutputFile(const std::string& pOutputFile); 89 90 bool hasOutputFile() const; 91 92private: 93 SymbolRenameMap m_SymbolRenames; 94 AddressMap m_AddressMap; 95 SectionMap m_SectionMap; 96 Assignments m_Assignments; 97 Assertions m_Assertions; 98 SearchDirs m_SearchDirs; 99 std::string m_Entry; 100 std::string m_OutputFile; 101}; 102 103} // namespace of mcld 104 105#endif 106 107