Set TEXTREL correctly when using a SECTIONS clause.
[deliverable/binutils-gdb.git] / gold / parameters.cc
CommitLineData
7e1edb90
ILT
1// parameters.cc -- general parameters for a link using gold
2
6cb15b7f
ILT
3// Copyright 2006, 2007 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
7e1edb90
ILT
23#include "gold.h"
24
25#include "options.h"
96803768 26#include "target.h"
7e1edb90
ILT
27#include "parameters.h"
28
29namespace gold
30{
31
32// Initialize the parameters from the options.
33
3c2fafa5 34Parameters::Parameters(Errors* errors)
c7912668 35 : errors_(errors), threads_(false), output_file_name_(NULL),
3c2fafa5 36 output_file_type_(OUTPUT_INVALID), sysroot_(),
e2827e5f 37 strip_(STRIP_INVALID), allow_shlib_undefined_(false),
a2b1aa12 38 symbolic_(false), demangle_(false), detect_odr_violations_(false),
c7912668 39 optimization_level_(0), export_dynamic_(false), debug_(0),
ad2d6943 40 is_doing_static_link_valid_(false), doing_static_link_(false),
96803768 41 is_target_valid_(false), target_(NULL)
7e1edb90 42{
3c2fafa5
ILT
43}
44
45// Set fields from the command line options.
46
47void
48Parameters::set_from_options(const General_options* options)
49{
c7912668 50 this->threads_ = options->threads();
3c2fafa5
ILT
51 this->output_file_name_ = options->output_file_name();
52 this->sysroot_ = options->sysroot();
e2827e5f 53 this->allow_shlib_undefined_ = options->allow_shlib_undefined();
3c2fafa5 54 this->symbolic_ = options->symbolic();
a2b1aa12 55 this->demangle_ = options->demangle();
a55ce7fe 56 this->detect_odr_violations_ = options->detect_odr_violations();
3c2fafa5
ILT
57 this->optimization_level_ = options->optimization_level();
58 this->export_dynamic_ = options->export_dynamic();
c7912668 59 this->debug_ = options->debug();
3c2fafa5 60
7e1edb90
ILT
61 if (options->is_shared())
62 this->output_file_type_ = OUTPUT_SHARED;
63 else if (options->is_relocatable())
64 this->output_file_type_ = OUTPUT_OBJECT;
65 else
66 this->output_file_type_ = OUTPUT_EXECUTABLE;
9e2dcb77
ILT
67
68 if (options->strip_all())
69 this->strip_ = STRIP_ALL;
70 else if (options->strip_debug())
71 this->strip_ = STRIP_DEBUG;
02d2ba74
ILT
72 else if (options->strip_debug_gdb())
73 this->strip_ = STRIP_DEBUG_UNUSED_BY_GDB;
9e2dcb77
ILT
74 else
75 this->strip_ = STRIP_NONE;
3c2fafa5
ILT
76
77 this->options_valid_ = true;
7e1edb90
ILT
78}
79
b3b74ddc
ILT
80// Set whether we are doing a static link.
81
82void
83Parameters::set_doing_static_link(bool doing_static_link)
84{
85 this->doing_static_link_ = doing_static_link;
86 this->is_doing_static_link_valid_ = true;
87}
88
96803768 89// Set the target.
9025d29d
ILT
90
91void
96803768 92Parameters::set_target(Target* target)
9025d29d 93{
96803768 94 if (!this->is_target_valid_)
9025d29d 95 {
96803768
ILT
96 this->target_ = target;
97 this->size_ = target->get_size();
98 this->is_big_endian_ = target->is_big_endian();
99 this->is_target_valid_ = true;
9025d29d
ILT
100 }
101 else
96803768 102 gold_assert(target == this->target_);
9025d29d
ILT
103}
104
105// Our local version of the variable, which is not const.
106
107static Parameters* static_parameters;
108
7e1edb90
ILT
109// The global variable.
110
111const Parameters* parameters;
112
113// Initialize the global variable.
114
115void
3c2fafa5
ILT
116initialize_parameters(Errors* errors)
117{
118 parameters = static_parameters = new Parameters(errors);
119}
120
121// Set values from the options.
122
123void
124set_parameters_from_options(const General_options* options)
7e1edb90 125{
3c2fafa5 126 static_parameters->set_from_options(options);
9025d29d
ILT
127}
128
b3b74ddc
ILT
129// Set whether we are doing a static link.
130
131void
132set_parameters_doing_static_link(bool doing_static_link)
133{
134 static_parameters->set_doing_static_link(doing_static_link);
135}
136
96803768 137// Set the target.
b3b74ddc 138
9025d29d 139void
96803768 140set_parameters_target(Target* target)
9025d29d 141{
96803768 142 static_parameters->set_target(target);
7e1edb90
ILT
143}
144
145} // End namespace gold.
This page took 0.063301 seconds and 4 git commands to generate.