summaryrefslogtreecommitdiff
path: root/gold/parameters.cc
diff options
context:
space:
mode:
authorDoug Kwan <dougkwan@google.com>2010-04-07 21:42:22 +0000
committerDoug Kwan <dougkwan@google.com>2010-04-07 21:42:22 +0000
commit7296d9338774c74e5a525f0c8f31c20f367997f5 (patch)
tree67b418679854fa1282c810a5ed529f3b56bedb4a /gold/parameters.cc
parent45ecb02a77c46951cc295f519e2c36c4f999a047 (diff)
2010-04-07 Doug Kwan <dougkwan@google.com>
* arm.cc: Replace "endianity" with "endianness" in comments. (Arm_exidx_cantunwind): Ditto. (Arm_relobj::Arm_relobj): Initialize merge_flags_and_attribures. (Arm_relobj::merge_flags_and_attributes): New method. (Arm_relobj::merge_flags_and_attributes_): New data member. (Arm_exidx_cantunwind::do_fixed_endian_write): Fix formatting. (Arm_relobj::scan_sections_for_stubs): Ditto. (Arm_relobj::do_read_symbols): Check to see if we really want to merge processor-specific flags and attributes. Exit early if an object is empty except for section names and the undefined symbol. (Target_arm::do_finalize_sections): Move check for ELF format to Arm_relobj::do_read_symbols. Merge processor specific flags and attributes from a regular object only when we have determined that it is aapropriate. Do not create an .ARM.attributes section in output if there is no regular input object. (Target_arm::merge_processor_specific_flags): Check --warn-mismatch before printing any error. (Target_arm::merge_object_attributes): Ditto. * gold.cc (queue_middle_tasks): Handle the case in which there is no regular object in input. * options.cc (General_options::parse_EB): New method. (General_options::parse_EL): Same. (General_options::General_options): Initialize endianness_. * options.h (-EB, -EL, -no-pipeline-knowledge, -p, --warn-mismatch): New options. (General_options::Endianness): New enum. (General_options::endianness): New method. (General_options::endianness_): New data member. * parameters.cc (Parameters::set_options): Check target endianness. (Parameters::set_target_once): Ditto. (Parameters::check_target_endianness): New method. (parameters_force_valid_target): If either -EL or -EB is specified, use it to define endianness of default target. * parameters.h (Parameters::check_target_endianness): New method declaration. * target.h (class Target): Change "endianity" to "endianness" in comments.
Diffstat (limited to 'gold/parameters.cc')
-rw-r--r--gold/parameters.cc38
1 files changed, 37 insertions, 1 deletions
diff --git a/gold/parameters.cc b/gold/parameters.cc
index 1d0f082e19..4430388a67 100644
--- a/gold/parameters.cc
+++ b/gold/parameters.cc
@@ -89,6 +89,8 @@ Parameters::set_options(const General_options* options)
// If --verbose is set, it acts as "--debug=files".
if (options->verbose())
this->debug_ |= DEBUG_FILES;
+ if (this->target_valid())
+ this->check_target_endianness();
}
void
@@ -113,6 +115,8 @@ Parameters::set_target_once(Target* target)
{
gold_assert(this->target_ == NULL);
this->target_ = target;
+ if (this->options_valid())
+ this->check_target_endianness();
}
// Clear the target, for testing.
@@ -181,6 +185,29 @@ Parameters::size_and_endianness() const
gold_unreachable();
}
+// If output endianness is specified in command line, check that it does
+// not conflict with the target.
+
+void
+Parameters::check_target_endianness()
+{
+ General_options::Endianness endianness = this->options().endianness();
+ if (endianness != General_options::ENDIANNESS_NOT_SET)
+ {
+ bool big_endian;
+ if (endianness == General_options::ENDIANNESS_BIG)
+ big_endian = true;
+ else
+ {
+ gold_assert(endianness == General_options::ENDIANNESS_LITTLE);
+ big_endian = false;;
+ }
+
+ if (this->target().is_big_endian() != big_endian)
+ gold_error(_("input file does not match -EB/EL option"));
+ }
+}
+
void
set_parameters_errors(Errors* errors)
{ static_parameters.set_errors(errors); }
@@ -227,9 +254,18 @@ parameters_force_valid_target()
}
// The GOLD_DEFAULT_xx macros are defined by the configure script.
+ bool is_big_endian;
+ General_options::Endianness endianness = parameters->options().endianness();
+ if (endianness == General_options::ENDIANNESS_BIG)
+ is_big_endian = true;
+ else if (endianness == General_options::ENDIANNESS_LITTLE)
+ is_big_endian = false;
+ else
+ is_big_endian = GOLD_DEFAULT_BIG_ENDIAN;
+
Target* target = select_target(elfcpp::GOLD_DEFAULT_MACHINE,
GOLD_DEFAULT_SIZE,
- GOLD_DEFAULT_BIG_ENDIAN,
+ is_big_endian,
elfcpp::GOLD_DEFAULT_OSABI,
0);
gold_assert(target != NULL);