OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [binutils-2.20.1/] [gold/] [parameters.h] - Blame information for rev 818

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
// parameters.h -- general parameters for a link using gold  -*- C++ -*-
2
 
3
// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
4
// Written by Ian Lance Taylor <iant@google.com>.
5
 
6
// This file is part of gold.
7
 
8
// This program is free software; you can redistribute it and/or modify
9
// it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation; either version 3 of the License, or
11
// (at your option) any later version.
12
 
13
// This program is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
 
18
// You should have received a copy of the GNU General Public License
19
// along with this program; if not, write to the Free Software
20
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21
// MA 02110-1301, USA.
22
 
23
#ifndef GOLD_PARAMETERS_H
24
#define GOLD_PARAMETERS_H
25
 
26
namespace gold
27
{
28
 
29
class General_options;
30
class Errors;
31
class Target;
32
template<int size, bool big_endian>
33
class Sized_target;
34
 
35
// Here we define the Parameters class which simply holds simple
36
// general parameters which apply to the entire link.  We use a global
37
// variable for this.  The parameters class holds three types of data:
38
//    1) An Errors struct.  Any part of the code that wants to log an
39
//       error can use parameters->errors().
40
//    2) A const General_options.  These are the options as read on
41
//       the commandline.
42
//    3) Target information, such as size and endian-ness.  This is
43
//       available as soon as we've decided on the Target (after
44
//       parsing the first .o file).
45
//    4) Whether we're doing a static link or not.  This is set
46
//       after all inputs have been read and we know if any is a
47
//       dynamic library.
48
 
49
class Parameters
50
{
51
 public:
52
  Parameters()
53
    : errors_(NULL), options_(NULL), target_(NULL),
54
      doing_static_link_valid_(false), doing_static_link_(false),
55
      debug_(0)
56
  { }
57
 
58
  // These should be called as soon as they are known.
59
  void
60
  set_errors(Errors* errors);
61
 
62
  void
63
  set_options(const General_options* options);
64
 
65
  void
66
  set_target(Target* target);
67
 
68
  void
69
  set_doing_static_link(bool doing_static_link);
70
 
71
  // Return the error object.
72
  Errors*
73
  errors() const
74
  { return this->errors_; }
75
 
76
  // Whether the options are valid.  This should not normally be
77
  // called, but it is needed by gold_exit.
78
  bool
79
  options_valid() const
80
  { return this->options_ != NULL; }
81
 
82
  // Return the options object.
83
  const General_options&
84
  options() const
85
  {
86
    gold_assert(this->options_valid());
87
    return *this->options_;
88
  }
89
 
90
  // Return whether the target field has been set.
91
  bool
92
  target_valid() const
93
  { return this->target_ != NULL; }
94
 
95
  // The target of the output file we are generating.
96
  const Target&
97
  target() const
98
  {
99
    gold_assert(this->target_valid());
100
    return *this->target_;
101
  }
102
 
103
  // The Sized_target of the output file.  The caller must request the
104
  // right size and endianness.
105
  template<int size, bool big_endian>
106
  Sized_target<size, big_endian>*
107
  sized_target() const
108
  {
109
    gold_assert(this->target_valid());
110
    return static_cast<Sized_target<size, big_endian>*>(this->target_);
111
  }
112
 
113
  // Clear the target, for testing.
114
  void
115
  clear_target()
116
  { this->target_ = NULL; }
117
 
118
  // Return true if TARGET is compatible with the current target.
119
  bool
120
  is_compatible_target(const Target*) const;
121
 
122
  bool
123
  doing_static_link() const
124
  {
125
    gold_assert(this->doing_static_link_valid_);
126
    return this->doing_static_link_;
127
  }
128
 
129
  // This is just a copy of options().debug().  We make a copy so we
130
  // don't have to #include options.h in order to inline
131
  // is_debugging_enabled, below.
132
  int
133
  debug() const
134
  {
135
    // This can be called before the options are set up.
136
    if (!this->options_valid())
137
      return 0;
138
    return debug_;
139
  }
140
 
141
  // A convenience routine for combining size and endianness.  It also
142
  // checks the HAVE_TARGET_FOO configure options and dies if the
143
  // current target's size/endianness is not supported according to
144
  // HAVE_TARGET_FOO.  Otherwise it returns this enum
145
  enum Target_size_endianness
146
  { TARGET_32_LITTLE, TARGET_32_BIG, TARGET_64_LITTLE, TARGET_64_BIG };
147
 
148
  Target_size_endianness
149
  size_and_endianness() const;
150
 
151
 
152
 private:
153
  Errors* errors_;
154
  const General_options* options_;
155
  Target* target_;
156
  bool doing_static_link_valid_;
157
  bool doing_static_link_;
158
  int debug_;
159
};
160
 
161
// This is a global variable.
162
extern const Parameters* parameters;
163
 
164
// We use free functions for these since they affect a global variable
165
// that is internal to parameters.cc.
166
 
167
extern void
168
set_parameters_errors(Errors* errors);
169
 
170
extern void
171
set_parameters_options(const General_options* options);
172
 
173
extern void
174
set_parameters_target(Target* target);
175
 
176
extern void
177
set_parameters_doing_static_link(bool doing_static_link);
178
 
179
// Ensure that the target to be valid by using the default target if
180
// necessary.
181
 
182
extern void
183
parameters_force_valid_target();
184
 
185
// Clear the current target, for testing.
186
 
187
extern void
188
parameters_clear_target();
189
 
190
// Return whether we are doing a particular debugging type.  The
191
// argument is one of the flags from debug.h.
192
 
193
inline bool
194
is_debugging_enabled(unsigned int type)
195
{ return (parameters->debug() & type) != 0; }
196
 
197
} // End namespace gold.
198
 
199
#endif // !defined(GOLD_PARAMETERS_H)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.