1 // parameters.h -- general parameters for a link using gold -*- C++ -*-
3 // Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
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.
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.
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.
23 #ifndef GOLD_PARAMETERS_H
24 #define GOLD_PARAMETERS_H
29 class General_options
;
33 // Here we define the Parameters class which simply holds simple
34 // general parameters which apply to the entire link. We use a global
35 // variable for this. The parameters class holds three types of data:
36 // 1) An Errors struct. Any part of the code that wants to log an
37 // error can use parameters->errors().
38 // 2) A const General_options. These are the options as read on
40 // 3) Target information, such as size and endian-ness. This is
41 // available as soon as we've decided on the Target (after
42 // parsing the first .o file).
43 // 4) Whether we're doing a static link or not. This is set
44 // after all inputs have been read and we know if any is a
51 : errors_(NULL
), options_(NULL
), target_(NULL
),
52 doing_static_link_valid_(false), doing_static_link_(false),
56 // These should be called as soon as they are known.
58 set_errors(Errors
* errors
);
61 set_options(const General_options
* options
);
64 set_target(const Target
* target
);
67 set_doing_static_link(bool doing_static_link
);
69 // Return the error object.
72 { return this->errors_
; }
74 // Whether the options are valid. This should not normally be
75 // called, but it is needed by gold_exit.
78 { return this->options_
!= NULL
; }
80 // Return the options object.
81 const General_options
&
84 gold_assert(this->options_valid());
85 return *this->options_
;
88 // Return whether the target field has been set.
91 { return this->target_
!= NULL
; }
93 // The target of the output file we are generating.
97 gold_assert(this->target_valid());
98 return *this->target_
;
101 // When we don't have an output file to associate a target, make a
102 // default one, with guesses about size and endianness.
104 default_target() const;
107 doing_static_link() const
109 gold_assert(this->doing_static_link_valid_
);
110 return this->doing_static_link_
;
113 // This is just a copy of options().debug(). We make a copy so we
114 // don't have to #include options.h in order to inline
115 // is_debugging_enabled, below.
119 // This can be called before the options are set up.
120 if (!this->options_valid())
125 // A convenience routine for combining size and endianness. It also
126 // checks the HAVE_TARGET_FOO configure options and dies if the
127 // current target's size/endianness is not supported according to
128 // HAVE_TARGET_FOO. Otherwise it returns this enum
129 enum Target_size_endianness
130 { TARGET_32_LITTLE
, TARGET_32_BIG
, TARGET_64_LITTLE
, TARGET_64_BIG
};
132 Target_size_endianness
133 size_and_endianness() const;
138 const General_options
* options_
;
139 const Target
* target_
;
140 bool doing_static_link_valid_
;
141 bool doing_static_link_
;
145 // This is a global variable.
146 extern const Parameters
* parameters
;
148 // We use free functions for these since they affect a global variable
149 // that is internal to parameters.cc.
152 set_parameters_errors(Errors
* errors
);
155 set_parameters_options(const General_options
* options
);
158 set_parameters_target(const Target
* target
);
161 set_parameters_doing_static_link(bool doing_static_link
);
163 // Return whether we are doing a particular debugging type. The
164 // argument is one of the flags from debug.h.
167 is_debugging_enabled(unsigned int type
)
168 { return (parameters
->debug() & type
) != 0; }
170 } // End namespace gold.
172 #endif // !defined(GOLD_PARAMETERS_H)