blob: 5b9c92bd70814cbc58e635ee42b1ea6682dc6ef3 [file] [log] [blame]
Shih-wei Liao22add6f2012-12-15 17:21:00 -08001//===- GeneralOptions.h ---------------------------------------------------===//
Shih-wei Liao5460a1f2012-03-16 22:41:16 -07002//
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 Hines37b74a32014-11-26 18:48:20 -08009#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 Hines0dea6bc2014-07-15 18:33:32 -070014#include <string>
15#include <vector>
16#include <set>
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070017
Shih-wei Liao22add6f2012-12-15 17:21:00 -080018namespace mcld {
19
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070020class Input;
Stephen Hines87f34652014-02-14 18:00:16 -080021class ZOption;
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070022
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070023/** \class GeneralOptions
24 * \brief GeneralOptions collects the options that not be one of the
25 * - input files
26 * - attribute of input files
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070027 */
Stephen Hines37b74a32014-11-26 18:48:20 -080028class GeneralOptions {
29 public:
Pirama Arumuga Nainar2bf3f882015-04-21 10:33:13 -070030 enum class StripSymbolMode {
Stephen Hines6f757552013-03-04 19:51:03 -080031 KeepAllSymbols,
32 StripTemporaries,
33 StripLocals,
34 StripAllSymbols
35 };
36
Pirama Arumuga Nainar2bf3f882015-04-21 10:33:13 -070037 enum class HashStyle : uint8_t {
38 Unknown = 0x0,
39 SystemV = 0x1,
40 GNU = 0x2,
41 Both = 0x3
42 };
Stephen Hines6f757552013-03-04 19:51:03 -080043
Pirama Arumuga Nainar2bf3f882015-04-21 10:33:13 -070044 enum class ICF {
45 Unknown,
46 None,
47 All,
48 Safe
49 };
Stephen Hines0dea6bc2014-07-15 18:33:32 -070050
Stephen Hines6f757552013-03-04 19:51:03 -080051 typedef std::vector<std::string> RpathList;
52 typedef RpathList::iterator rpath_iterator;
53 typedef RpathList::const_iterator const_rpath_iterator;
54
Stephen Hines87f34652014-02-14 18:00:16 -080055 typedef std::vector<std::string> ScriptList;
56 typedef ScriptList::iterator script_iterator;
57 typedef ScriptList::const_iterator const_script_iterator;
58
Stephen Hines6f757552013-03-04 19:51:03 -080059 typedef std::vector<std::string> AuxiliaryList;
60 typedef AuxiliaryList::iterator aux_iterator;
61 typedef AuxiliaryList::const_iterator const_aux_iterator;
62
Stephen Hines0dea6bc2014-07-15 18:33:32 -070063 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 Hines37b74a32014-11-26 18:48:20 -080069 public:
Zonr Changaffc1502012-07-16 14:28:23 +080070 GeneralOptions();
71 ~GeneralOptions();
72
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070073 /// trace
Stephen Hines37b74a32014-11-26 18:48:20 -080074 void setTrace(bool pEnableTrace = true) { m_bTrace = pEnableTrace; }
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070075
Stephen Hines37b74a32014-11-26 18:48:20 -080076 bool trace() const { return m_bTrace; }
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070077
Stephen Hines37b74a32014-11-26 18:48:20 -080078 void setBsymbolic(bool pBsymbolic = true) { m_Bsymbolic = pBsymbolic; }
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070079
Stephen Hines37b74a32014-11-26 18:48:20 -080080 bool Bsymbolic() const { return m_Bsymbolic; }
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070081
Stephen Hines37b74a32014-11-26 18:48:20 -080082 void setPIE(bool pPIE = true) { m_bPIE = pPIE; }
Zonr Changaffc1502012-07-16 14:28:23 +080083
Stephen Hines37b74a32014-11-26 18:48:20 -080084 bool isPIE() const { return m_bPIE; }
Zonr Changaffc1502012-07-16 14:28:23 +080085
Stephen Hines37b74a32014-11-26 18:48:20 -080086 void setBgroup(bool pBgroup = true) { m_Bgroup = pBgroup; }
Zonr Changaffc1502012-07-16 14:28:23 +080087
Stephen Hines37b74a32014-11-26 18:48:20 -080088 bool Bgroup() const { return m_Bgroup; }
Zonr Changaffc1502012-07-16 14:28:23 +080089
Stephen Hines37b74a32014-11-26 18:48:20 -080090 void setDyld(const std::string& pDyld) { m_Dyld = pDyld; }
Zonr Changaffc1502012-07-16 14:28:23 +080091
Stephen Hines37b74a32014-11-26 18:48:20 -080092 const std::string& dyld() const { return m_Dyld; }
Zonr Changaffc1502012-07-16 14:28:23 +080093
Stephen Hines37b74a32014-11-26 18:48:20 -080094 bool hasDyld() const { return !m_Dyld.empty(); }
Zonr Changaffc1502012-07-16 14:28:23 +080095
Shih-wei Liao22add6f2012-12-15 17:21:00 -080096 void setSOName(const std::string& pName);
97
Stephen Hines37b74a32014-11-26 18:48:20 -080098 const std::string& soname() const { return m_SOName; }
Shih-wei Liao22add6f2012-12-15 17:21:00 -080099
Stephen Hines37b74a32014-11-26 18:48:20 -0800100 void setVerbose(int8_t pVerbose = -1) { m_Verbose = pVerbose; }
Zonr Changaffc1502012-07-16 14:28:23 +0800101
Stephen Hines37b74a32014-11-26 18:48:20 -0800102 int8_t verbose() const { return m_Verbose; }
Zonr Changaffc1502012-07-16 14:28:23 +0800103
Stephen Hines37b74a32014-11-26 18:48:20 -0800104 void setMaxErrorNum(int16_t pNum) { m_MaxErrorNum = pNum; }
Zonr Changaffc1502012-07-16 14:28:23 +0800105
Stephen Hines37b74a32014-11-26 18:48:20 -0800106 int16_t maxErrorNum() const { return m_MaxErrorNum; }
Zonr Changaffc1502012-07-16 14:28:23 +0800107
Stephen Hines37b74a32014-11-26 18:48:20 -0800108 void setMaxWarnNum(int16_t pNum) { m_MaxWarnNum = pNum; }
Zonr Changaffc1502012-07-16 14:28:23 +0800109
Stephen Hines37b74a32014-11-26 18:48:20 -0800110 int16_t maxWarnNum() const { return m_MaxWarnNum; }
Zonr Changaffc1502012-07-16 14:28:23 +0800111
Stephen Hines37b74a32014-11-26 18:48:20 -0800112 void setColor(bool pEnabled = true) { m_bColor = pEnabled; }
Zonr Changaffc1502012-07-16 14:28:23 +0800113
Stephen Hines37b74a32014-11-26 18:48:20 -0800114 bool color() const { return m_bColor; }
Zonr Changaffc1502012-07-16 14:28:23 +0800115
Stephen Hines37b74a32014-11-26 18:48:20 -0800116 void setNoUndefined(bool pEnable = true) {
117 m_NoUndefined = (pEnable ? YES : NO);
118 }
Zonr Changaffc1502012-07-16 14:28:23 +0800119
Stephen Hines04c59f32015-04-07 16:30:20 -0700120 void setNumSpareDTags(uint32_t pNum) {
121 m_NumSpareDTags = pNum;
122 }
123
124 unsigned getNumSpareDTags() const { return m_NumSpareDTags; }
125
Stephen Hines37b74a32014-11-26 18:48:20 -0800126 void setMulDefs(bool pEnable = true) { m_MulDefs = (pEnable ? YES : NO); }
Zonr Changaffc1502012-07-16 14:28:23 +0800127
Stephen Hines37b74a32014-11-26 18:48:20 -0800128 void setEhFrameHdr(bool pEnable = true) { m_bCreateEhFrameHdr = pEnable; }
Zonr Changaffc1502012-07-16 14:28:23 +0800129
130 /// ----- the -z options ----- ///
131 void addZOption(const mcld::ZOption& pOption);
132
Stephen Hines37b74a32014-11-26 18:48:20 -0800133 bool hasCombReloc() const { return m_bCombReloc; }
Zonr Changaffc1502012-07-16 14:28:23 +0800134
Stephen Hines37b74a32014-11-26 18:48:20 -0800135 bool hasNoUndefined() const { return (Unknown != m_NoUndefined); }
Stephen Hines87f34652014-02-14 18:00:16 -0800136
Stephen Hines37b74a32014-11-26 18:48:20 -0800137 bool isNoUndefined() const { return (YES == m_NoUndefined); }
Zonr Changaffc1502012-07-16 14:28:23 +0800138
Stephen Hines37b74a32014-11-26 18:48:20 -0800139 bool hasStackSet() const { return (Unknown != m_ExecStack); }
Zonr Changaffc1502012-07-16 14:28:23 +0800140
Stephen Hines37b74a32014-11-26 18:48:20 -0800141 bool hasExecStack() const { return (YES == m_ExecStack); }
Zonr Changaffc1502012-07-16 14:28:23 +0800142
Stephen Hines37b74a32014-11-26 18:48:20 -0800143 bool hasInitFirst() const { return m_bInitFirst; }
Zonr Changaffc1502012-07-16 14:28:23 +0800144
Stephen Hines37b74a32014-11-26 18:48:20 -0800145 bool hasInterPose() const { return m_bInterPose; }
Zonr Changaffc1502012-07-16 14:28:23 +0800146
Stephen Hines37b74a32014-11-26 18:48:20 -0800147 bool hasLoadFltr() const { return m_bLoadFltr; }
Zonr Changaffc1502012-07-16 14:28:23 +0800148
Stephen Hines37b74a32014-11-26 18:48:20 -0800149 bool hasMulDefs() const { return (Unknown != m_MulDefs); }
Stephen Hines87f34652014-02-14 18:00:16 -0800150
Stephen Hines37b74a32014-11-26 18:48:20 -0800151 bool isMulDefs() const { return (YES == m_MulDefs); }
Zonr Changaffc1502012-07-16 14:28:23 +0800152
Stephen Hines37b74a32014-11-26 18:48:20 -0800153 bool hasNoCopyReloc() const { return m_bNoCopyReloc; }
Zonr Changaffc1502012-07-16 14:28:23 +0800154
Stephen Hines37b74a32014-11-26 18:48:20 -0800155 bool hasNoDefaultLib() const { return m_bNoDefaultLib; }
Zonr Changaffc1502012-07-16 14:28:23 +0800156
Stephen Hines37b74a32014-11-26 18:48:20 -0800157 bool hasNoDelete() const { return m_bNoDelete; }
Zonr Changaffc1502012-07-16 14:28:23 +0800158
Stephen Hines37b74a32014-11-26 18:48:20 -0800159 bool hasNoDLOpen() const { return m_bNoDLOpen; }
Zonr Changaffc1502012-07-16 14:28:23 +0800160
Stephen Hines37b74a32014-11-26 18:48:20 -0800161 bool hasNoDump() const { return m_bNoDump; }
Zonr Changaffc1502012-07-16 14:28:23 +0800162
Stephen Hines37b74a32014-11-26 18:48:20 -0800163 bool hasRelro() const { return m_bRelro; }
Zonr Changaffc1502012-07-16 14:28:23 +0800164
Stephen Hines37b74a32014-11-26 18:48:20 -0800165 bool hasNow() const { return m_bNow; }
Zonr Changaffc1502012-07-16 14:28:23 +0800166
Stephen Hines37b74a32014-11-26 18:48:20 -0800167 bool hasOrigin() const { return m_bOrigin; }
Zonr Changaffc1502012-07-16 14:28:23 +0800168
Stephen Hines37b74a32014-11-26 18:48:20 -0800169 uint64_t commPageSize() const { return m_CommPageSize; }
Zonr Changaffc1502012-07-16 14:28:23 +0800170
Stephen Hines37b74a32014-11-26 18:48:20 -0800171 uint64_t maxPageSize() const { return m_MaxPageSize; }
Zonr Changaffc1502012-07-16 14:28:23 +0800172
Stephen Hines37b74a32014-11-26 18:48:20 -0800173 bool hasEhFrameHdr() const { return m_bCreateEhFrameHdr; }
Zonr Changaffc1502012-07-16 14:28:23 +0800174
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800175 // -n, --nmagic
Stephen Hines37b74a32014-11-26 18:48:20 -0800176 void setNMagic(bool pMagic = true) { m_bNMagic = pMagic; }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800177
Stephen Hines37b74a32014-11-26 18:48:20 -0800178 bool nmagic() const { return m_bNMagic; }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800179
180 // -N, --omagic
Stephen Hines37b74a32014-11-26 18:48:20 -0800181 void setOMagic(bool pMagic = true) { m_bOMagic = pMagic; }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800182
Stephen Hines37b74a32014-11-26 18:48:20 -0800183 bool omagic() const { return m_bOMagic; }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800184
185 // -S, --strip-debug
Stephen Hines37b74a32014-11-26 18:48:20 -0800186 void setStripDebug(bool pStripDebug = true) { m_bStripDebug = pStripDebug; }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800187
Stephen Hines37b74a32014-11-26 18:48:20 -0800188 bool stripDebug() const { return m_bStripDebug; }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800189
190 // -E, --export-dynamic
Stephen Hines37b74a32014-11-26 18:48:20 -0800191 void setExportDynamic(bool pExportDynamic = true) {
192 m_bExportDynamic = pExportDynamic;
193 }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800194
Stephen Hines37b74a32014-11-26 18:48:20 -0800195 bool exportDynamic() const { return m_bExportDynamic; }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800196
197 // --warn-shared-textrel
Stephen Hines37b74a32014-11-26 18:48:20 -0800198 void setWarnSharedTextrel(bool pWarnSharedTextrel = true) {
199 m_bWarnSharedTextrel = pWarnSharedTextrel;
200 }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800201
Stephen Hines37b74a32014-11-26 18:48:20 -0800202 bool warnSharedTextrel() const { return m_bWarnSharedTextrel; }
Shih-wei Liaod0fbbb22013-01-03 06:23:31 -0800203
Stephen Hines37b74a32014-11-26 18:48:20 -0800204 void setBinaryInput(bool pBinaryInput = true) {
205 m_bBinaryInput = pBinaryInput;
206 }
Shih-wei Liaod0fbbb22013-01-03 06:23:31 -0800207
Stephen Hines37b74a32014-11-26 18:48:20 -0800208 bool isBinaryInput() const { return m_bBinaryInput; }
Shih-wei Liaod0fbbb22013-01-03 06:23:31 -0800209
Stephen Hines37b74a32014-11-26 18:48:20 -0800210 void setDefineCommon(bool pEnable = true) { m_bDefineCommon = pEnable; }
Shih-wei Liaod0fbbb22013-01-03 06:23:31 -0800211
Stephen Hines37b74a32014-11-26 18:48:20 -0800212 bool isDefineCommon() const { return m_bDefineCommon; }
Shih-wei Liaod0fbbb22013-01-03 06:23:31 -0800213
Stephen Hines37b74a32014-11-26 18:48:20 -0800214 void setFatalWarnings(bool pEnable = true) { m_bFatalWarnings = pEnable; }
Shih-wei Liaod0fbbb22013-01-03 06:23:31 -0800215
Stephen Hines37b74a32014-11-26 18:48:20 -0800216 bool isFatalWarnings() const { return m_bFatalWarnings; }
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800217
Stephen Hines37b74a32014-11-26 18:48:20 -0800218 StripSymbolMode getStripSymbolMode() const { return m_StripSymbols; }
Stephen Hines6f757552013-03-04 19:51:03 -0800219
Stephen Hines37b74a32014-11-26 18:48:20 -0800220 void setStripSymbols(StripSymbolMode pMode) { m_StripSymbols = pMode; }
Stephen Hines6f757552013-03-04 19:51:03 -0800221
Stephen Hines37b74a32014-11-26 18:48:20 -0800222 void setNewDTags(bool pEnable = true) { m_bNewDTags = pEnable; }
Stephen Hines6f757552013-03-04 19:51:03 -0800223
Stephen Hines37b74a32014-11-26 18:48:20 -0800224 bool hasNewDTags() const { return m_bNewDTags; }
Stephen Hines6f757552013-03-04 19:51:03 -0800225
Stephen Hines37b74a32014-11-26 18:48:20 -0800226 void setNoStdlib(bool pEnable = true) { m_bNoStdlib = pEnable; }
Stephen Hines6f757552013-03-04 19:51:03 -0800227
Stephen Hines37b74a32014-11-26 18:48:20 -0800228 bool nostdlib() const { return m_bNoStdlib; }
Stephen Hines6f757552013-03-04 19:51:03 -0800229
Stephen Hinesf7ac0f12013-05-03 19:09:24 -0700230 // -M, --print-map
Stephen Hines37b74a32014-11-26 18:48:20 -0800231 void setPrintMap(bool pEnable = true) { m_bPrintMap = pEnable; }
Stephen Hinesf7ac0f12013-05-03 19:09:24 -0700232
Stephen Hines37b74a32014-11-26 18:48:20 -0800233 bool printMap() const { return m_bPrintMap; }
Stephen Hinesf7ac0f12013-05-03 19:09:24 -0700234
Stephen Hines37b74a32014-11-26 18:48:20 -0800235 void setWarnMismatch(bool pEnable = true) { m_bWarnMismatch = pEnable; }
Stephen Hines87f34652014-02-14 18:00:16 -0800236
Stephen Hines37b74a32014-11-26 18:48:20 -0800237 bool warnMismatch() const { return m_bWarnMismatch; }
Stephen Hines87f34652014-02-14 18:00:16 -0800238
239 // --gc-sections
Stephen Hines37b74a32014-11-26 18:48:20 -0800240 void setGCSections(bool pEnable = true) { m_bGCSections = pEnable; }
Stephen Hines87f34652014-02-14 18:00:16 -0800241
Stephen Hines37b74a32014-11-26 18:48:20 -0800242 bool GCSections() const { return m_bGCSections; }
Stephen Hines87f34652014-02-14 18:00:16 -0800243
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700244 // --print-gc-sections
Stephen Hines37b74a32014-11-26 18:48:20 -0800245 void setPrintGCSections(bool pEnable = true) { m_bPrintGCSections = pEnable; }
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700246
Stephen Hines37b74a32014-11-26 18:48:20 -0800247 bool getPrintGCSections() const { return m_bPrintGCSections; }
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700248
Stephen Hines87f34652014-02-14 18:00:16 -0800249 // --ld-generated-unwind-info
Stephen Hines37b74a32014-11-26 18:48:20 -0800250 void setGenUnwindInfo(bool pEnable = true) { m_bGenUnwindInfo = pEnable; }
Stephen Hines87f34652014-02-14 18:00:16 -0800251
Stephen Hines37b74a32014-11-26 18:48:20 -0800252 bool genUnwindInfo() const { return m_bGenUnwindInfo; }
Stephen Hines87f34652014-02-14 18:00:16 -0800253
Pirama Arumuga Nainar2bf3f882015-04-21 10:33:13 -0700254 HashStyle getHashStyle() const { return m_HashStyle; }
Stephen Hines6f757552013-03-04 19:51:03 -0800255
Pirama Arumuga Nainar2bf3f882015-04-21 10:33:13 -0700256 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 Hines6f757552013-03-04 19:51:03 -0800265
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700266 ICF getICFMode() const { return m_ICF; }
267
Stephen Hines37b74a32014-11-26 18:48:20 -0800268 void setICFMode(ICF pMode) { m_ICF = pMode; }
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700269
270 size_t getICFIterations() const { return m_ICFIterations; }
271
Stephen Hines37b74a32014-11-26 18:48:20 -0800272 void setICFIterations(size_t pNum) { m_ICFIterations = pNum; }
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700273
274 bool printICFSections() const { return m_bPrintICFSections; }
275
Pirama Arumuga Nainar2bf3f882015-04-21 10:33:13 -0700276 void setPrintICFSections(bool pPrintICFSections = true) {
Stephen Hines37b74a32014-11-26 18:48:20 -0800277 m_bPrintICFSections = pPrintICFSections;
278 }
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700279
Stephen Hines6f757552013-03-04 19:51:03 -0800280 // ----- link-in rpath ----- //
281 const RpathList& getRpathList() const { return m_RpathList; }
Stephen Hines37b74a32014-11-26 18:48:20 -0800282 RpathList& getRpathList() { return m_RpathList; }
Stephen Hines6f757552013-03-04 19:51:03 -0800283
284 const_rpath_iterator rpath_begin() const { return m_RpathList.begin(); }
Stephen Hines37b74a32014-11-26 18:48:20 -0800285 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 Hines6f757552013-03-04 19:51:03 -0800288
Stephen Hines87f34652014-02-14 18:00:16 -0800289 // ----- link-in script ----- //
290 const ScriptList& getScriptList() const { return m_ScriptList; }
Stephen Hines37b74a32014-11-26 18:48:20 -0800291 ScriptList& getScriptList() { return m_ScriptList; }
Stephen Hines87f34652014-02-14 18:00:16 -0800292
293 const_script_iterator script_begin() const { return m_ScriptList.begin(); }
Stephen Hines37b74a32014-11-26 18:48:20 -0800294 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 Hines87f34652014-02-14 18:00:16 -0800297
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700298 // ----- -u/--undefined, undefined symbols ----- //
299 const UndefSymList& getUndefSymList() const { return m_UndefSymList; }
Stephen Hines37b74a32014-11-26 18:48:20 -0800300 UndefSymList& getUndefSymList() { return m_UndefSymList; }
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700301
Stephen Hines37b74a32014-11-26 18:48:20 -0800302 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 Hines0dea6bc2014-07-15 18:33:32 -0700306
Stephen Hines37b74a32014-11-26 18:48:20 -0800307 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 Hines0dea6bc2014-07-15 18:33:32 -0700311
Stephen Hines6f757552013-03-04 19:51:03 -0800312 // ----- filter and auxiliary filter ----- //
Stephen Hines37b74a32014-11-26 18:48:20 -0800313 void setFilter(const std::string& pFilter) { m_Filter = pFilter; }
Stephen Hines6f757552013-03-04 19:51:03 -0800314
Stephen Hines37b74a32014-11-26 18:48:20 -0800315 const std::string& filter() const { return m_Filter; }
Stephen Hines6f757552013-03-04 19:51:03 -0800316
Stephen Hines37b74a32014-11-26 18:48:20 -0800317 bool hasFilter() const { return !m_Filter.empty(); }
Stephen Hines6f757552013-03-04 19:51:03 -0800318
319 const AuxiliaryList& getAuxiliaryList() const { return m_AuxiliaryList; }
Stephen Hines37b74a32014-11-26 18:48:20 -0800320 AuxiliaryList& getAuxiliaryList() { return m_AuxiliaryList; }
Stephen Hines6f757552013-03-04 19:51:03 -0800321
322 const_aux_iterator aux_begin() const { return m_AuxiliaryList.begin(); }
Stephen Hines37b74a32014-11-26 18:48:20 -0800323 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 Hines6f757552013-03-04 19:51:03 -0800326
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700327 // ----- exclude libs ----- //
Stephen Hines37b74a32014-11-26 18:48:20 -0800328 ExcludeLIBS& excludeLIBS() { return m_ExcludeLIBS; }
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700329
330 bool isInExcludeLIBS(const Input& pInput) const;
331
Stephen Hines37b74a32014-11-26 18:48:20 -0800332 const char* getVersionString() const { return PACKAGE_NAME " " MCLD_VERSION; }
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700333
Stephen Hines37b74a32014-11-26 18:48:20 -0800334 private:
335 enum status { YES, NO, Unknown };
Zonr Changaffc1502012-07-16 14:28:23 +0800336
Stephen Hines37b74a32014-11-26 18:48:20 -0800337 private:
Shih-wei Liao5460a1f2012-03-16 22:41:16 -0700338 std::string m_DefaultLDScript;
Zonr Changaffc1502012-07-16 14:28:23 +0800339 std::string m_Dyld;
Shih-wei Liao22add6f2012-12-15 17:21:00 -0800340 std::string m_SOName;
Stephen Hines37b74a32014-11-26 18:48:20 -0800341 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 Hines04c59f32015-04-07 16:30:20 -0700344 unsigned m_NumSpareDTags; // --spare-dynamic-tags
Stephen Hines37b74a32014-11-26 18:48:20 -0800345 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 Hines0dea6bc2014-07-15 18:33:32 -0700384 ICF m_ICF;
385 size_t m_ICFIterations;
Stephen Hines6f757552013-03-04 19:51:03 -0800386 StripSymbolMode m_StripSymbols;
387 RpathList m_RpathList;
Stephen Hines87f34652014-02-14 18:00:16 -0800388 ScriptList m_ScriptList;
Stephen Hines37b74a32014-11-26 18:48:20 -0800389 UndefSymList m_UndefSymList; // -u [symbol], --undefined [symbol]
Pirama Arumuga Nainar2bf3f882015-04-21 10:33:13 -0700390 HashStyle m_HashStyle;
Stephen Hines6f757552013-03-04 19:51:03 -0800391 std::string m_Filter;
392 AuxiliaryList m_AuxiliaryList;
Stephen Hines0dea6bc2014-07-15 18:33:32 -0700393 ExcludeLIBS m_ExcludeLIBS;
Shih-wei Liao5460a1f2012-03-16 22:41:16 -0700394};
395
Stephen Hines37b74a32014-11-26 18:48:20 -0800396} // namespace mcld
Shih-wei Liao5460a1f2012-03-16 22:41:16 -0700397
Stephen Hines37b74a32014-11-26 18:48:20 -0800398#endif // MCLD_GENERALOPTIONS_H_