Home | History | Annotate | Download | only in mcld
      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_LINKER_SCRIPT_H
     10 #define MCLD_LINKER_SCRIPT_H
     11 #ifdef ENABLE_UNITTEST
     12 #include <gtest.h>
     13 #endif
     14 #include <string>
     15 #include <llvm/ADT/StringRef.h>
     16 #include <mcld/ADT/StringEntry.h>
     17 #include <mcld/ADT/StringHash.h>
     18 #include <mcld/ADT/HashTable.h>
     19 #include <mcld/Object/SectionMap.h>
     20 #include <mcld/MC/SearchDirs.h>
     21 
     22 namespace mcld {
     23 
     24 /** \class LinkerScript
     25  *
     26  */
     27 class LinkerScript
     28 {
     29 public:
     30   typedef HashTable<StringEntry<llvm::StringRef>,
     31                     hash::StringHash<hash::ELF>,
     32                     StringEntryFactory<llvm::StringRef> > SymbolRenameMap;
     33 
     34   typedef HashTable<StringEntry<uint64_t>,
     35                     hash::StringHash<hash::ELF>,
     36                     StringEntryFactory<uint64_t> > AddressMap;
     37 
     38   typedef HashTable<StringEntry<llvm::StringRef>,
     39                     hash::StringHash<hash::ELF>,
     40                     StringEntryFactory<llvm::StringRef> > DefSymMap;
     41 
     42 public:
     43   LinkerScript();
     44 
     45   ~LinkerScript();
     46 
     47   const SymbolRenameMap& renameMap() const { return m_SymbolRenames; }
     48   SymbolRenameMap&       renameMap()       { return m_SymbolRenames; }
     49 
     50   const AddressMap& addressMap() const { return m_AddressMap; }
     51   AddressMap&       addressMap()       { return m_AddressMap; }
     52 
     53   const SectionMap& sectionMap() const { return m_SectionMap; }
     54   SectionMap&       sectionMap()       { return m_SectionMap; }
     55 
     56   const DefSymMap& defSymMap() const { return m_DefSymMap; }
     57   DefSymMap&       defSymMap()       { return m_DefSymMap; }
     58 
     59   /// search directory
     60   const SearchDirs& directories() const { return m_SearchDirs; }
     61   SearchDirs&       directories()       { return m_SearchDirs; }
     62 
     63   /// sysroot
     64   const sys::fs::Path& sysroot() const;
     65 
     66   void setSysroot(const sys::fs::Path &pPath);
     67 
     68   bool hasSysroot() const;
     69 
     70 private:
     71   SymbolRenameMap m_SymbolRenames;
     72   AddressMap m_AddressMap;
     73   SectionMap m_SectionMap;
     74   DefSymMap m_DefSymMap;
     75   SearchDirs m_SearchDirs;
     76 };
     77 
     78 } // namespace of mcld
     79 
     80 #endif
     81 
     82