From 9025d29d14ae287d2bc338ef1b0bfa043799e15c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 26 Sep 2007 07:01:35 +0000 Subject: Put size and endianness in parameters. --- gold/parameters.cc | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'gold/parameters.cc') diff --git a/gold/parameters.cc b/gold/parameters.cc index 462eeea..db377f8 100644 --- a/gold/parameters.cc +++ b/gold/parameters.cc @@ -31,7 +31,8 @@ namespace gold // Initialize the parameters from the options. Parameters::Parameters(const General_options* options) - : optimization_level_(options->optimization_level()) + : is_size_and_endian_valid_(false), size_(0), is_big_endian_(false), + optimization_level_(options->optimization_level()) { if (options->is_shared()) this->output_file_type_ = OUTPUT_SHARED; @@ -41,6 +42,28 @@ Parameters::Parameters(const General_options* options) this->output_file_type_ = OUTPUT_EXECUTABLE; } +// Set the size and endianness. + +void +Parameters::set_size_and_endianness(int size, bool is_big_endian) +{ + if (!this->is_size_and_endian_valid_) + { + this->size_ = size; + this->is_big_endian_ = is_big_endian; + this->is_size_and_endian_valid_ = true; + } + else + { + gold_assert(size == this->size_); + gold_assert(is_big_endian == this->is_big_endian_); + } +} + +// Our local version of the variable, which is not const. + +static Parameters* static_parameters; + // The global variable. const Parameters* parameters; @@ -50,7 +73,13 @@ const Parameters* parameters; void initialize_parameters(const General_options* options) { - parameters = new Parameters(options); + parameters = static_parameters = new Parameters(options); +} + +void +set_parameters_size_and_endianness(int size, bool is_big_endian) +{ + static_parameters->set_size_and_endianness(size, is_big_endian); } } // End namespace gold. -- cgit v1.1