1 //===- TargetControlOptions.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/TargetControlOptions.h>
10 #include <mcld/LinkerConfig.h>
11 #include <mcld/Support/MsgHandling.h>
12
13 namespace {
14
15 llvm::cl::opt<int> ArgGPSize("G",
16 llvm::cl::desc("Set the maximum size of objects to be optimized using GP"),
17 llvm::cl::init(8));
18
19 llvm::cl::opt<bool> ArgWarnSharedTextrel("warn-shared-textrel",
20 llvm::cl::ZeroOrMore,
21 llvm::cl::desc("Warn if adding DT_TEXTREL in a shared object."),
22 llvm::cl::init(false));
23
24 // Not supported yet {
25 llvm::cl::opt<bool> ArgFIXCA8("fix-cortex-a8",
26 llvm::cl::desc("Enable Cortex-A8 Thumb-2 branch erratum fix"),
27 llvm::cl::init(false));
28
29 llvm::cl::opt<bool> ArgEB("EB",
30 llvm::cl::desc("Link big-endian objects. This affects the output format."),
31 llvm::cl::init(false));
32
33 llvm::cl::opt<bool> ArgEL("EL",
34 llvm::cl::desc("Link little-endian objects. This affects the output format."),
35 llvm::cl::init(false));
36
37 llvm::cl::opt<bool> ArgSVR4Compatibility("Qy",
38 llvm::cl::desc("This option is ignored for SVR4 compatibility"),
39 llvm::cl::init(false));
40
41 // } Not supported yet
42
43 } // anonymous namespace
44
45 using namespace mcld;
46
47 //===----------------------------------------------------------------------===//
48 // TargetControlOptions
49 //===----------------------------------------------------------------------===//
TargetControlOptions()50 TargetControlOptions::TargetControlOptions()
51 : m_GPSize(ArgGPSize),
52 m_WarnSharedTextrel(ArgWarnSharedTextrel),
53 m_FIXCA8(ArgFIXCA8),
54 m_EB(ArgEB),
55 m_EL(ArgEL),
56 m_SVR4Compatibility(ArgSVR4Compatibility) {
57 }
58
parse(LinkerConfig & pConfig)59 bool TargetControlOptions::parse(LinkerConfig& pConfig)
60 {
61 // set -G [size]
62 pConfig.options().setGPSize(m_GPSize);
63
64 // set --warn-shared-textrel
65 pConfig.options().setWarnSharedTextrel(m_WarnSharedTextrel);
66
67 // set --fix-cortex-a8
68 if (m_FIXCA8)
69 mcld::warning(mcld::diag::warn_unsupported_option) << m_FIXCA8.ArgStr;
70
71 return true;
72 }
73
74