1 // parameters.cc -- general parameters for a link using gold
3 // Copyright 2006, 2007 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.
27 #include "target-select.h"
33 Parameters::set_errors(Errors
* errors
)
35 gold_assert(this->errors_
== NULL
);
36 this->errors_
= errors
;
40 Parameters::set_options(const General_options
* options
)
42 gold_assert(!this->options_valid());
43 this->options_
= options
;
44 // For speed, we make our own copy of the debug variable.
45 this->debug_
= this->options().debug();
49 Parameters::set_doing_static_link(bool doing_static_link
)
51 gold_assert(!this->doing_static_link_valid_
);
52 this->doing_static_link_
= doing_static_link
;
53 this->doing_static_link_valid_
= true;
57 Parameters::set_target(const Target
* target
)
59 if (!this->target_valid())
60 this->target_
= target
;
62 gold_assert(target
== this->target_
);
65 // The x86_64 kernel build converts a binary file to an object file
66 // using -r --format binary --oformat elf32-i386 foo.o. In order to
67 // support that for gold we support determining the default target
68 // choice from the output format. We recognize names that the GNU
72 Parameters::default_target() const
74 gold_assert(this->options_valid());
75 if (this->options().oformat_string() != NULL
)
78 = select_target_by_name(this->options().oformat_string());
82 gold_error(_("unrecognized output format %s"),
83 this->options().oformat_string());
86 // The GOLD_DEFAULT_xx macros are defined by the configure script.
87 const Target
* target
= select_target(elfcpp::GOLD_DEFAULT_MACHINE
,
89 GOLD_DEFAULT_BIG_ENDIAN
,
91 gold_assert(target
!= NULL
);
95 Parameters::Target_size_endianness
96 Parameters::size_and_endianness() const
98 if (this->target().get_size() == 32)
100 if (!this->target().is_big_endian())
102 #ifdef HAVE_TARGET_32_LITTLE
103 return TARGET_32_LITTLE
;
110 #ifdef HAVE_TARGET_32_BIG
111 return TARGET_32_BIG
;
117 else if (parameters
->target().get_size() == 64)
119 if (!parameters
->target().is_big_endian())
121 #ifdef HAVE_TARGET_64_LITTLE
122 return TARGET_64_LITTLE
;
129 #ifdef HAVE_TARGET_64_BIG
130 return TARGET_64_BIG
;
141 // Our local version of the variable, which is not const.
143 static Parameters static_parameters
;
145 // The global variable.
147 const Parameters
* parameters
= &static_parameters
;
150 set_parameters_errors(Errors
* errors
)
151 { static_parameters
.set_errors(errors
); }
154 set_parameters_options(const General_options
* options
)
155 { static_parameters
.set_options(options
); }
158 set_parameters_target(const Target
* target
)
159 { static_parameters
.set_target(target
); }
162 set_parameters_doing_static_link(bool doing_static_link
)
163 { static_parameters
.set_doing_static_link(doing_static_link
); }
165 } // End namespace gold.