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