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