1//===- GeneralOptions.cpp -------------------------------------------------===//
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#include <mcld/GeneralOptions.h>
10#include <mcld/MC/MCLDInput.h>
11
12using namespace mcld;
13
14//===----------------------------------------------------------------------===//
15// GeneralOptions
16//===----------------------------------------------------------------------===//
17GeneralOptions::GeneralOptions()
18  : m_pDefaultBitcode(NULL),
19    m_Verbose(-1),
20    m_MaxErrorNum(-1),
21    m_MaxWarnNum(-1),
22    m_ExecStack(Unknown),
23    m_CommPageSize(0x0),
24    m_MaxPageSize(0x0),
25    m_bCombReloc(true),
26    m_bNoUndefined(false),
27    m_bInitFirst(false),
28    m_bInterPose(false),
29    m_bLoadFltr(false),
30    m_bMulDefs(false),
31    m_bNoCopyReloc(false),
32    m_bNoDefaultLib(false),
33    m_bNoDelete(false),
34    m_bNoDLOpen(false),
35    m_bNoDump(false),
36    m_bRelro(false),
37    m_bNow(false),
38    m_bOrigin(false),
39    m_bTrace(false),
40    m_Bsymbolic(false),
41    m_Bgroup(false),
42    m_bPIE(false),
43    m_bColor(true),
44    m_bCreateEhFrameHdr(false),
45    m_bNMagic(false),
46    m_bOMagic(false),
47    m_bStripDebug(false),
48    m_bExportDynamic(false),
49    m_bWarnSharedTextrel(false),
50    m_bBinaryInput(false),
51    m_bDefineCommon(false),
52    m_bFatalWarnings(false),
53    m_bNewDTags(false),
54    m_bNoStdlib(false),
55    m_GPSize(8),
56    m_StripSymbols(KeepAllSymbols),
57    m_HashStyle(SystemV) {
58}
59
60GeneralOptions::~GeneralOptions()
61{
62}
63
64bool GeneralOptions::hasDefaultLDScript() const
65{
66  return true;
67}
68
69const char* GeneralOptions::defaultLDScript() const
70{
71  return NULL;
72}
73
74void GeneralOptions::setDefaultLDScript(const std::string& pFilename)
75{
76}
77
78void GeneralOptions::setSOName(const std::string& pName)
79{
80  size_t pos = pName.find_last_of(sys::fs::separator);
81  if (std::string::npos == pos)
82    m_SOName = pName;
83  else
84    m_SOName = pName.substr(pos + 1);
85}
86
87void GeneralOptions::addZOption(const ZOption& pOption)
88{
89  switch (pOption.kind()) {
90    case ZOption::CombReloc:
91      m_bCombReloc = true;
92      break;
93    case ZOption::NoCombReloc:
94      m_bCombReloc = false;
95      break;
96    case ZOption::Defs:
97      m_bNoUndefined = true;
98      break;
99    case ZOption::ExecStack:
100      m_ExecStack = YES;
101      break;
102    case ZOption::NoExecStack:
103      m_ExecStack = NO;
104      break;
105    case ZOption::InitFirst:
106      m_bInitFirst = true;
107      break;
108    case ZOption::InterPose:
109      m_bInterPose = true;
110      break;
111    case ZOption::LoadFltr:
112      m_bLoadFltr = true;
113      break;
114    case ZOption::MulDefs:
115      m_bMulDefs = true;
116      break;
117    case ZOption::NoCopyReloc:
118      m_bNoCopyReloc = true;
119      break;
120    case ZOption::NoDefaultLib:
121      m_bNoDefaultLib = true;
122      break;
123    case ZOption::NoDelete:
124      m_bNoDelete = true;
125      break;
126    case ZOption::NoDLOpen:
127      m_bNoDLOpen = true;
128      break;
129    case ZOption::NoDump:
130      m_bNoDump = true;
131      break;
132    case ZOption::NoRelro:
133      m_bRelro = false;
134      break;
135    case ZOption::Relro:
136      m_bRelro = true;
137      break;
138    case ZOption::Lazy:
139      m_bNow = false;
140      break;
141    case ZOption::Now:
142      m_bNow = true;
143      break;
144    case ZOption::Origin:
145      m_bOrigin = true;
146      break;
147    case ZOption::CommPageSize:
148      m_CommPageSize = pOption.pageSize();
149      break;
150    case ZOption::MaxPageSize:
151      m_MaxPageSize = pOption.pageSize();
152      break;
153    case ZOption::Unknown:
154    default:
155      assert(false && "Not a recognized -z option.");
156      break;
157  }
158}
159