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