Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 1 | //===- GeneralOptions.h ---------------------------------------------------===// |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 9 | #ifndef MCLD_GENERALOPTIONS_H_ |
| 10 | #define MCLD_GENERALOPTIONS_H_ |
| 11 | #include "mcld/Config/Config.h" |
| 12 | #include "mcld/Support/RealPath.h" |
| 13 | #include "mcld/Support/FileSystem.h" |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 14 | #include <string> |
| 15 | #include <vector> |
| 16 | #include <set> |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 17 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 18 | namespace mcld { |
| 19 | |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 20 | class Input; |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 21 | class ZOption; |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 22 | |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 23 | /** \class GeneralOptions |
| 24 | * \brief GeneralOptions collects the options that not be one of the |
| 25 | * - input files |
| 26 | * - attribute of input files |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 27 | */ |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 28 | class GeneralOptions { |
| 29 | public: |
Pirama Arumuga Nainar | 2bf3f88 | 2015-04-21 10:33:13 -0700 | [diff] [blame] | 30 | enum class StripSymbolMode { |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 31 | KeepAllSymbols, |
| 32 | StripTemporaries, |
| 33 | StripLocals, |
| 34 | StripAllSymbols |
| 35 | }; |
| 36 | |
Pirama Arumuga Nainar | 2bf3f88 | 2015-04-21 10:33:13 -0700 | [diff] [blame] | 37 | enum class HashStyle : uint8_t { |
| 38 | Unknown = 0x0, |
| 39 | SystemV = 0x1, |
| 40 | GNU = 0x2, |
| 41 | Both = 0x3 |
| 42 | }; |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 43 | |
Pirama Arumuga Nainar | 2bf3f88 | 2015-04-21 10:33:13 -0700 | [diff] [blame] | 44 | enum class ICF { |
| 45 | Unknown, |
| 46 | None, |
| 47 | All, |
| 48 | Safe |
| 49 | }; |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 50 | |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 51 | typedef std::vector<std::string> RpathList; |
| 52 | typedef RpathList::iterator rpath_iterator; |
| 53 | typedef RpathList::const_iterator const_rpath_iterator; |
| 54 | |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 55 | typedef std::vector<std::string> ScriptList; |
| 56 | typedef ScriptList::iterator script_iterator; |
| 57 | typedef ScriptList::const_iterator const_script_iterator; |
| 58 | |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 59 | typedef std::vector<std::string> AuxiliaryList; |
| 60 | typedef AuxiliaryList::iterator aux_iterator; |
| 61 | typedef AuxiliaryList::const_iterator const_aux_iterator; |
| 62 | |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 63 | typedef std::vector<std::string> UndefSymList; |
| 64 | typedef UndefSymList::iterator undef_sym_iterator; |
| 65 | typedef UndefSymList::const_iterator const_undef_sym_iterator; |
| 66 | |
| 67 | typedef std::set<std::string> ExcludeLIBS; |
| 68 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 69 | public: |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 70 | GeneralOptions(); |
| 71 | ~GeneralOptions(); |
| 72 | |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 73 | /// trace |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 74 | void setTrace(bool pEnableTrace = true) { m_bTrace = pEnableTrace; } |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 75 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 76 | bool trace() const { return m_bTrace; } |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 77 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 78 | void setBsymbolic(bool pBsymbolic = true) { m_Bsymbolic = pBsymbolic; } |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 79 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 80 | bool Bsymbolic() const { return m_Bsymbolic; } |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 81 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 82 | void setPIE(bool pPIE = true) { m_bPIE = pPIE; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 83 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 84 | bool isPIE() const { return m_bPIE; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 85 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 86 | void setBgroup(bool pBgroup = true) { m_Bgroup = pBgroup; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 87 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 88 | bool Bgroup() const { return m_Bgroup; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 89 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 90 | void setDyld(const std::string& pDyld) { m_Dyld = pDyld; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 91 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 92 | const std::string& dyld() const { return m_Dyld; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 93 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 94 | bool hasDyld() const { return !m_Dyld.empty(); } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 95 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 96 | void setSOName(const std::string& pName); |
| 97 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 98 | const std::string& soname() const { return m_SOName; } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 99 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 100 | void setVerbose(int8_t pVerbose = -1) { m_Verbose = pVerbose; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 101 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 102 | int8_t verbose() const { return m_Verbose; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 103 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 104 | void setMaxErrorNum(int16_t pNum) { m_MaxErrorNum = pNum; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 105 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 106 | int16_t maxErrorNum() const { return m_MaxErrorNum; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 107 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 108 | void setMaxWarnNum(int16_t pNum) { m_MaxWarnNum = pNum; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 109 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 110 | int16_t maxWarnNum() const { return m_MaxWarnNum; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 111 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 112 | void setColor(bool pEnabled = true) { m_bColor = pEnabled; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 113 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 114 | bool color() const { return m_bColor; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 115 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 116 | void setNoUndefined(bool pEnable = true) { |
| 117 | m_NoUndefined = (pEnable ? YES : NO); |
| 118 | } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 119 | |
Stephen Hines | 04c59f3 | 2015-04-07 16:30:20 -0700 | [diff] [blame] | 120 | void setNumSpareDTags(uint32_t pNum) { |
| 121 | m_NumSpareDTags = pNum; |
| 122 | } |
| 123 | |
| 124 | unsigned getNumSpareDTags() const { return m_NumSpareDTags; } |
| 125 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 126 | void setMulDefs(bool pEnable = true) { m_MulDefs = (pEnable ? YES : NO); } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 127 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 128 | void setEhFrameHdr(bool pEnable = true) { m_bCreateEhFrameHdr = pEnable; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 129 | |
| 130 | /// ----- the -z options ----- /// |
| 131 | void addZOption(const mcld::ZOption& pOption); |
| 132 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 133 | bool hasCombReloc() const { return m_bCombReloc; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 134 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 135 | bool hasNoUndefined() const { return (Unknown != m_NoUndefined); } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 136 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 137 | bool isNoUndefined() const { return (YES == m_NoUndefined); } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 138 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 139 | bool hasStackSet() const { return (Unknown != m_ExecStack); } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 140 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 141 | bool hasExecStack() const { return (YES == m_ExecStack); } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 142 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 143 | bool hasInitFirst() const { return m_bInitFirst; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 144 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 145 | bool hasInterPose() const { return m_bInterPose; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 146 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 147 | bool hasLoadFltr() const { return m_bLoadFltr; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 148 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 149 | bool hasMulDefs() const { return (Unknown != m_MulDefs); } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 150 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 151 | bool isMulDefs() const { return (YES == m_MulDefs); } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 152 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 153 | bool hasNoCopyReloc() const { return m_bNoCopyReloc; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 154 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 155 | bool hasNoDefaultLib() const { return m_bNoDefaultLib; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 156 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 157 | bool hasNoDelete() const { return m_bNoDelete; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 158 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 159 | bool hasNoDLOpen() const { return m_bNoDLOpen; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 160 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 161 | bool hasNoDump() const { return m_bNoDump; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 162 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 163 | bool hasRelro() const { return m_bRelro; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 164 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 165 | bool hasNow() const { return m_bNow; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 166 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 167 | bool hasOrigin() const { return m_bOrigin; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 168 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 169 | uint64_t commPageSize() const { return m_CommPageSize; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 170 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 171 | uint64_t maxPageSize() const { return m_MaxPageSize; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 172 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 173 | bool hasEhFrameHdr() const { return m_bCreateEhFrameHdr; } |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 174 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 175 | // -n, --nmagic |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 176 | void setNMagic(bool pMagic = true) { m_bNMagic = pMagic; } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 177 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 178 | bool nmagic() const { return m_bNMagic; } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 179 | |
| 180 | // -N, --omagic |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 181 | void setOMagic(bool pMagic = true) { m_bOMagic = pMagic; } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 182 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 183 | bool omagic() const { return m_bOMagic; } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 184 | |
| 185 | // -S, --strip-debug |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 186 | void setStripDebug(bool pStripDebug = true) { m_bStripDebug = pStripDebug; } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 187 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 188 | bool stripDebug() const { return m_bStripDebug; } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 189 | |
| 190 | // -E, --export-dynamic |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 191 | void setExportDynamic(bool pExportDynamic = true) { |
| 192 | m_bExportDynamic = pExportDynamic; |
| 193 | } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 194 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 195 | bool exportDynamic() const { return m_bExportDynamic; } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 196 | |
| 197 | // --warn-shared-textrel |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 198 | void setWarnSharedTextrel(bool pWarnSharedTextrel = true) { |
| 199 | m_bWarnSharedTextrel = pWarnSharedTextrel; |
| 200 | } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 201 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 202 | bool warnSharedTextrel() const { return m_bWarnSharedTextrel; } |
Shih-wei Liao | d0fbbb2 | 2013-01-03 06:23:31 -0800 | [diff] [blame] | 203 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 204 | void setBinaryInput(bool pBinaryInput = true) { |
| 205 | m_bBinaryInput = pBinaryInput; |
| 206 | } |
Shih-wei Liao | d0fbbb2 | 2013-01-03 06:23:31 -0800 | [diff] [blame] | 207 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 208 | bool isBinaryInput() const { return m_bBinaryInput; } |
Shih-wei Liao | d0fbbb2 | 2013-01-03 06:23:31 -0800 | [diff] [blame] | 209 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 210 | void setDefineCommon(bool pEnable = true) { m_bDefineCommon = pEnable; } |
Shih-wei Liao | d0fbbb2 | 2013-01-03 06:23:31 -0800 | [diff] [blame] | 211 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 212 | bool isDefineCommon() const { return m_bDefineCommon; } |
Shih-wei Liao | d0fbbb2 | 2013-01-03 06:23:31 -0800 | [diff] [blame] | 213 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 214 | void setFatalWarnings(bool pEnable = true) { m_bFatalWarnings = pEnable; } |
Shih-wei Liao | d0fbbb2 | 2013-01-03 06:23:31 -0800 | [diff] [blame] | 215 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 216 | bool isFatalWarnings() const { return m_bFatalWarnings; } |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 217 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 218 | StripSymbolMode getStripSymbolMode() const { return m_StripSymbols; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 219 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 220 | void setStripSymbols(StripSymbolMode pMode) { m_StripSymbols = pMode; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 221 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 222 | void setNewDTags(bool pEnable = true) { m_bNewDTags = pEnable; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 223 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 224 | bool hasNewDTags() const { return m_bNewDTags; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 225 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 226 | void setNoStdlib(bool pEnable = true) { m_bNoStdlib = pEnable; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 227 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 228 | bool nostdlib() const { return m_bNoStdlib; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 229 | |
Stephen Hines | f7ac0f1 | 2013-05-03 19:09:24 -0700 | [diff] [blame] | 230 | // -M, --print-map |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 231 | void setPrintMap(bool pEnable = true) { m_bPrintMap = pEnable; } |
Stephen Hines | f7ac0f1 | 2013-05-03 19:09:24 -0700 | [diff] [blame] | 232 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 233 | bool printMap() const { return m_bPrintMap; } |
Stephen Hines | f7ac0f1 | 2013-05-03 19:09:24 -0700 | [diff] [blame] | 234 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 235 | void setWarnMismatch(bool pEnable = true) { m_bWarnMismatch = pEnable; } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 236 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 237 | bool warnMismatch() const { return m_bWarnMismatch; } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 238 | |
| 239 | // --gc-sections |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 240 | void setGCSections(bool pEnable = true) { m_bGCSections = pEnable; } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 241 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 242 | bool GCSections() const { return m_bGCSections; } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 243 | |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 244 | // --print-gc-sections |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 245 | void setPrintGCSections(bool pEnable = true) { m_bPrintGCSections = pEnable; } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 246 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 247 | bool getPrintGCSections() const { return m_bPrintGCSections; } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 248 | |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 249 | // --ld-generated-unwind-info |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 250 | void setGenUnwindInfo(bool pEnable = true) { m_bGenUnwindInfo = pEnable; } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 251 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 252 | bool genUnwindInfo() const { return m_bGenUnwindInfo; } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 253 | |
Pirama Arumuga Nainar | 2bf3f88 | 2015-04-21 10:33:13 -0700 | [diff] [blame] | 254 | HashStyle getHashStyle() const { return m_HashStyle; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 255 | |
Pirama Arumuga Nainar | 2bf3f88 | 2015-04-21 10:33:13 -0700 | [diff] [blame] | 256 | bool hasGNUHash() const { |
| 257 | return m_HashStyle == HashStyle::GNU || m_HashStyle == HashStyle::Both; |
| 258 | } |
| 259 | |
| 260 | bool hasSysVHash() const { |
| 261 | return m_HashStyle == HashStyle::SystemV || m_HashStyle == HashStyle::Both; |
| 262 | } |
| 263 | |
| 264 | void setHashStyle(HashStyle pStyle) { m_HashStyle = pStyle; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 265 | |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 266 | ICF getICFMode() const { return m_ICF; } |
| 267 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 268 | void setICFMode(ICF pMode) { m_ICF = pMode; } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 269 | |
| 270 | size_t getICFIterations() const { return m_ICFIterations; } |
| 271 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 272 | void setICFIterations(size_t pNum) { m_ICFIterations = pNum; } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 273 | |
| 274 | bool printICFSections() const { return m_bPrintICFSections; } |
| 275 | |
Pirama Arumuga Nainar | 2bf3f88 | 2015-04-21 10:33:13 -0700 | [diff] [blame] | 276 | void setPrintICFSections(bool pPrintICFSections = true) { |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 277 | m_bPrintICFSections = pPrintICFSections; |
| 278 | } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 279 | |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 280 | // ----- link-in rpath ----- // |
| 281 | const RpathList& getRpathList() const { return m_RpathList; } |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 282 | RpathList& getRpathList() { return m_RpathList; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 283 | |
| 284 | const_rpath_iterator rpath_begin() const { return m_RpathList.begin(); } |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 285 | rpath_iterator rpath_begin() { return m_RpathList.begin(); } |
| 286 | const_rpath_iterator rpath_end() const { return m_RpathList.end(); } |
| 287 | rpath_iterator rpath_end() { return m_RpathList.end(); } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 288 | |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 289 | // ----- link-in script ----- // |
| 290 | const ScriptList& getScriptList() const { return m_ScriptList; } |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 291 | ScriptList& getScriptList() { return m_ScriptList; } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 292 | |
| 293 | const_script_iterator script_begin() const { return m_ScriptList.begin(); } |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 294 | script_iterator script_begin() { return m_ScriptList.begin(); } |
| 295 | const_script_iterator script_end() const { return m_ScriptList.end(); } |
| 296 | script_iterator script_end() { return m_ScriptList.end(); } |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 297 | |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 298 | // ----- -u/--undefined, undefined symbols ----- // |
| 299 | const UndefSymList& getUndefSymList() const { return m_UndefSymList; } |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 300 | UndefSymList& getUndefSymList() { return m_UndefSymList; } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 301 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 302 | const_undef_sym_iterator undef_sym_begin() const { |
| 303 | return m_UndefSymList.begin(); |
| 304 | } |
| 305 | undef_sym_iterator undef_sym_begin() { return m_UndefSymList.begin(); } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 306 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 307 | const_undef_sym_iterator undef_sym_end() const { |
| 308 | return m_UndefSymList.end(); |
| 309 | } |
| 310 | undef_sym_iterator undef_sym_end() { return m_UndefSymList.end(); } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 311 | |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 312 | // ----- filter and auxiliary filter ----- // |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 313 | void setFilter(const std::string& pFilter) { m_Filter = pFilter; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 314 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 315 | const std::string& filter() const { return m_Filter; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 316 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 317 | bool hasFilter() const { return !m_Filter.empty(); } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 318 | |
| 319 | const AuxiliaryList& getAuxiliaryList() const { return m_AuxiliaryList; } |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 320 | AuxiliaryList& getAuxiliaryList() { return m_AuxiliaryList; } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 321 | |
| 322 | const_aux_iterator aux_begin() const { return m_AuxiliaryList.begin(); } |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 323 | aux_iterator aux_begin() { return m_AuxiliaryList.begin(); } |
| 324 | const_aux_iterator aux_end() const { return m_AuxiliaryList.end(); } |
| 325 | aux_iterator aux_end() { return m_AuxiliaryList.end(); } |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 326 | |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 327 | // ----- exclude libs ----- // |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 328 | ExcludeLIBS& excludeLIBS() { return m_ExcludeLIBS; } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 329 | |
| 330 | bool isInExcludeLIBS(const Input& pInput) const; |
| 331 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 332 | const char* getVersionString() const { return PACKAGE_NAME " " MCLD_VERSION; } |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 333 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 334 | private: |
| 335 | enum status { YES, NO, Unknown }; |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 336 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 337 | private: |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 338 | std::string m_DefaultLDScript; |
Zonr Chang | affc150 | 2012-07-16 14:28:23 +0800 | [diff] [blame] | 339 | std::string m_Dyld; |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 340 | std::string m_SOName; |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 341 | int8_t m_Verbose; // --verbose[=0,1,2] |
| 342 | uint16_t m_MaxErrorNum; // --error-limit=N |
| 343 | uint16_t m_MaxWarnNum; // --warning-limit=N |
Stephen Hines | 04c59f3 | 2015-04-07 16:30:20 -0700 | [diff] [blame] | 344 | unsigned m_NumSpareDTags; // --spare-dynamic-tags |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 345 | status m_ExecStack; // execstack, noexecstack |
| 346 | status m_NoUndefined; // defs, --no-undefined |
| 347 | status m_MulDefs; // muldefs, --allow-multiple-definition |
| 348 | uint64_t m_CommPageSize; // common-page-size=value |
| 349 | uint64_t m_MaxPageSize; // max-page-size=value |
| 350 | bool m_bCombReloc : 1; // combreloc, nocombreloc |
| 351 | bool m_bInitFirst : 1; // initfirst |
| 352 | bool m_bInterPose : 1; // interpose |
| 353 | bool m_bLoadFltr : 1; // loadfltr |
| 354 | bool m_bNoCopyReloc : 1; // nocopyreloc |
| 355 | bool m_bNoDefaultLib : 1; // nodefaultlib |
| 356 | bool m_bNoDelete : 1; // nodelete |
| 357 | bool m_bNoDLOpen : 1; // nodlopen |
| 358 | bool m_bNoDump : 1; // nodump |
| 359 | bool m_bRelro : 1; // relro, norelro |
| 360 | bool m_bNow : 1; // lazy, now |
| 361 | bool m_bOrigin : 1; // origin |
| 362 | bool m_bTrace : 1; // --trace |
| 363 | bool m_Bsymbolic : 1; // --Bsymbolic |
| 364 | bool m_Bgroup : 1; |
| 365 | bool m_bPIE : 1; |
| 366 | bool m_bColor : 1; // --color[=true,false,auto] |
| 367 | bool m_bCreateEhFrameHdr : 1; // --eh-frame-hdr |
| 368 | bool m_bNMagic : 1; // -n, --nmagic |
| 369 | bool m_bOMagic : 1; // -N, --omagic |
| 370 | bool m_bStripDebug : 1; // -S, --strip-debug |
| 371 | bool m_bExportDynamic : 1; // -E, --export-dynamic |
| 372 | bool m_bWarnSharedTextrel : 1; // --warn-shared-textrel |
| 373 | bool m_bBinaryInput : 1; // -b [input-format], --format=[input-format] |
| 374 | bool m_bDefineCommon : 1; // -d, -dc, -dp |
| 375 | bool m_bFatalWarnings : 1; // --fatal-warnings |
| 376 | bool m_bNewDTags : 1; // --enable-new-dtags |
| 377 | bool m_bNoStdlib : 1; // -nostdlib |
| 378 | bool m_bPrintMap : 1; // --print-map |
| 379 | bool m_bWarnMismatch : 1; // --no-warn-mismatch |
| 380 | bool m_bGCSections : 1; // --gc-sections |
| 381 | bool m_bPrintGCSections : 1; // --print-gc-sections |
| 382 | bool m_bGenUnwindInfo : 1; // --ld-generated-unwind-info |
| 383 | bool m_bPrintICFSections : 1; // --print-icf-sections |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 384 | ICF m_ICF; |
| 385 | size_t m_ICFIterations; |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 386 | StripSymbolMode m_StripSymbols; |
| 387 | RpathList m_RpathList; |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 388 | ScriptList m_ScriptList; |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 389 | UndefSymList m_UndefSymList; // -u [symbol], --undefined [symbol] |
Pirama Arumuga Nainar | 2bf3f88 | 2015-04-21 10:33:13 -0700 | [diff] [blame] | 390 | HashStyle m_HashStyle; |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 391 | std::string m_Filter; |
| 392 | AuxiliaryList m_AuxiliaryList; |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 393 | ExcludeLIBS m_ExcludeLIBS; |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 394 | }; |
| 395 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 396 | } // namespace mcld |
Shih-wei Liao | 5460a1f | 2012-03-16 22:41:16 -0700 | [diff] [blame] | 397 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 398 | #endif // MCLD_GENERALOPTIONS_H_ |