1 //===- Linker.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 10 #ifndef ALONE_SUPPORT_LINKER_CONFIG_H 11 #define ALONE_SUPPORT_LINKER_CONFIG_H 12 13 #include <string> 14 15 #include <mcld/LinkerConfig.h> 16 #include <mcld/LinkerScript.h> 17 #include <mcld/Support/TargetRegistry.h> 18 #include <mcld/LD/DiagnosticLineInfo.h> 19 #include <mcld/LD/DiagnosticPrinter.h> 20 21 namespace alone { 22 23 class LinkerConfig { 24 private: 25 //===--------------------------------------------------------------------===// 26 // Available Configurations 27 //===--------------------------------------------------------------------===// 28 const std::string mTriple; 29 std::string mSOName; 30 31 private: 32 //===--------------------------------------------------------------------===// 33 // These are generated by LinkerConfig during initialize(). 34 //===--------------------------------------------------------------------===// 35 const mcld::Target *mTarget; 36 bool initializeTarget(); 37 38 mcld::LinkerConfig *mLDConfig; 39 bool initializeLDInfo(); 40 41 mcld::LinkerScript *mLDScript; 42 bool initializeLDScript(); 43 44 mcld::DiagnosticLineInfo *mDiagLineInfo; 45 mcld::DiagnosticPrinter *mDiagPrinter; 46 bool initializeDiagnostic(); 47 48 public: 49 enum ZOptionEnum { 50 kCombReloc = 1 << 0, ///< [on] -z combreloc, [off] -z nocombreloc 51 kDefs = 1 << 1, ///< -z defs 52 kExecStack = 1 << 2, ///< [on] -z execstack, [off] -z noexecstack 53 kInitFirst = 1 << 3, ///< -z initfirst 54 kInterPose = 1 << 4, ///< -z interpose 55 kLoadFltr = 1 << 5, ///< -z loadfltr 56 kMulDefs = 1 << 6, ///< -z muldefs 57 kNoCopyReloc = 1 << 7, ///< -z nocopyreloc 58 kNoDefaultLib = 1 << 8, ///< -z nodefaultlib 59 kNoDelete = 1 << 9, ///< -z nodelete 60 kNoDLOpen = 1 << 10, ///< -z nodlopen 61 kNoDump = 1 << 11, ///< -z nodump 62 kRelro = 1 << 12, ///< [on] -z relro, [off] -z norelro 63 kLazy = 1 << 13, ///< [on] -z lazy, [off] -z now 64 kOrigin = 1 << 14, ///< -z origin 65 kZOptionMask = 0xFFFF 66 }; 67 68 public: 69 //===--------------------------------------------------------------------===// 70 // Getters 71 //===--------------------------------------------------------------------===// getTriple()72 inline const std::string &getTriple() const 73 { return mTriple; } 74 getTarget()75 inline const mcld::Target *getTarget() const 76 { return mTarget; } 77 getLDConfig()78 inline mcld::LinkerConfig* getLDConfig() 79 { return mLDConfig; } 80 getLDConfig()81 inline const mcld::LinkerConfig* getLDConfig() const 82 { return mLDConfig; } 83 getLDScript()84 inline mcld::LinkerScript* getLDScript() 85 { return mLDScript; } 86 getLDScript()87 inline const mcld::LinkerScript* getLDScript() const 88 { return mLDScript; } 89 90 bool isShared() const; 91 getSOName()92 inline std::string getSOName() const 93 { return mSOName; } 94 95 void setShared(bool pEnable = true); 96 97 void setBsymbolic(bool pEnable = true); 98 99 void setDefineCommon(bool pEnable = true); 100 101 void setSOName(const std::string &pSOName); 102 103 void setDyld(const std::string &pDyld); 104 105 void setSysRoot(const std::string &pSysRoot); 106 107 void setZOption(unsigned int pOptions); 108 109 void addWrap(const std::string &pWrapSymbol); 110 111 void addPortable(const std::string &pPortableSymbol); 112 113 void addSearchDir(const std::string &pDir); 114 115 public: 116 LinkerConfig(const std::string& pTriple); 117 118 virtual ~LinkerConfig(); 119 }; 120 121 } // end namespace alone 122 123 #endif // ALONE_SUPPORT_LINKER_CONFIG_H 124