• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef BCC_SUPPORT_LINKER_CONFIG_H
18 #define BCC_SUPPORT_LINKER_CONFIG_H
19 
20 #include <string>
21 
22 #include <mcld/LinkerConfig.h>
23 #include <mcld/Support/TargetRegistry.h>
24 #include <mcld/LD/DiagnosticLineInfo.h>
25 #include <mcld/LD/DiagnosticPrinter.h>
26 
27 namespace bcc {
28 
29 class LinkerConfig {
30 private:
31   //===--------------------------------------------------------------------===//
32   // Available Configurations
33   //===--------------------------------------------------------------------===//
34   const std::string mTriple;
35   std::string mSOName;
36 
37 private:
38   //===--------------------------------------------------------------------===//
39   // These are generated by LinkerConfig during initialize().
40   //===--------------------------------------------------------------------===//
41   const mcld::Target *mTarget;
42   bool initializeTarget();
43 
44   mcld::LinkerConfig *mLDConfig;
45   bool initializeLDInfo();
46 
47   mcld::DiagnosticLineInfo *mDiagLineInfo;
48   mcld::DiagnosticPrinter *mDiagPrinter;
49   bool initializeDiagnostic();
50 
51 public:
52   enum ZOptionEnum {
53     kCombReloc     = 1 << 0,  ///< [on] -z combreloc, [off] -z nocombreloc
54     kDefs          = 1 << 1,  ///< -z defs
55     kExecStack     = 1 << 2,  ///< [on] -z execstack, [off] -z noexecstack
56     kInitFirst     = 1 << 3,  ///< -z initfirst
57     kInterPose     = 1 << 4,  ///< -z interpose
58     kLoadFltr      = 1 << 5,  ///< -z loadfltr
59     kMulDefs       = 1 << 6,  ///< -z muldefs
60     kNoCopyReloc   = 1 << 7,  ///< -z nocopyreloc
61     kNoDefaultLib  = 1 << 8,  ///< -z nodefaultlib
62     kNoDelete      = 1 << 9,  ///< -z nodelete
63     kNoDLOpen      = 1 << 10, ///< -z nodlopen
64     kNoDump        = 1 << 11, ///< -z nodump
65     kRelro         = 1 << 12, ///< [on] -z relro, [off] -z norelro
66     kLazy          = 1 << 13, ///< [on] -z lazy, [off] -z now
67     kOrigin        = 1 << 14, ///< -z origin
68     kZOptionMask   = 0xFFFF
69   };
70 
71 public:
72   //===--------------------------------------------------------------------===//
73   // Getters
74   //===--------------------------------------------------------------------===//
getTriple()75   inline const std::string &getTriple() const
76   { return mTriple; }
77 
getTarget()78   inline const mcld::Target *getTarget() const
79   { return mTarget; }
80 
getLDConfig()81   inline mcld::LinkerConfig* getLDConfig()
82   { return mLDConfig; }
83 
getLDConfig()84   inline const mcld::LinkerConfig* getLDConfig() const
85   { return mLDConfig; }
86 
87   bool isShared() const;
88 
getSOName()89   inline std::string getSOName() const
90   { return mSOName; }
91 
92   void setShared(bool pEnable = true);
93 
94   void setBsymbolic(bool pEnable = true);
95 
96   void setDefineCommon(bool pEnable = true);
97 
98   void setSOName(const std::string &pSOName);
99 
100   void setDyld(const std::string &pDyld);
101 
102   void setSysRoot(const std::string &pSysRoot);
103 
104   void setZOption(unsigned int pOptions);
105 
106   void addWrap(const std::string &pWrapSymbol);
107 
108   void addPortable(const std::string &pPortableSymbol);
109 
110   void addSearchDir(const std::string &pDir);
111 
112 public:
113   LinkerConfig(const std::string& pTriple);
114 
115   virtual ~LinkerConfig();
116 };
117 
118 } // end namespace bcc
119 
120 #endif // BCC_SUPPORT_LINKER_CONFIG_H
121