diff --git a/gold/incremental-dump.cc b/gold/incremental-dump.cc index 9e750cb..bd5bdb3 100644 --- a/gold/incremental-dump.cc +++ b/gold/incremental-dump.cc @@ -62,7 +62,7 @@ main(int argc, char** argv) return 1; } - Incremental_binary* inc = open_incremental_binary(file); + Incremental_binary* inc = open_incremental_binary(filename, file); if (inc == NULL) { diff --git a/gold/incremental.cc b/gold/incremental.cc index 4af4ef3..2f7dc93 100644 --- a/gold/incremental.cc +++ b/gold/incremental.cc @@ -320,7 +320,7 @@ namespace template Incremental_binary* -make_sized_incremental_binary(Output_file* file, +make_sized_incremental_binary(const std::string& name, Output_file* file, const elfcpp::Ehdr& ehdr) { Target* target = select_target(ehdr.get_e_machine(), size, big_endian, @@ -333,6 +333,11 @@ make_sized_incremental_binary(Output_file* file, return NULL; } + if (!parameters->target_valid()) + set_parameters_target(target); + else if (target != ¶meters->target()) + gold_error(_("%s: incompatible target"), name.c_str()); + return new Sized_incremental_binary(file, ehdr, target); } @@ -343,7 +348,7 @@ make_sized_incremental_binary(Output_file* file, // should be opened. Incremental_binary* -open_incremental_binary(Output_file* file) +open_incremental_binary(const std::string& name, Output_file* file) { off_t filesize = file->filesize(); int want = elfcpp::Elf_recognizer::max_header_size; @@ -374,7 +379,7 @@ open_incremental_binary(Output_file* file) { #ifdef HAVE_TARGET_32_BIG result = make_sized_incremental_binary<32, true>( - file, elfcpp::Ehdr<32, true>(p)); + name, file, elfcpp::Ehdr<32, true>(p)); #else explain_no_incremental(_("unsupported file: 32-bit, big-endian")); #endif @@ -383,7 +388,7 @@ open_incremental_binary(Output_file* file) { #ifdef HAVE_TARGET_32_LITTLE result = make_sized_incremental_binary<32, false>( - file, elfcpp::Ehdr<32, false>(p)); + name, file, elfcpp::Ehdr<32, false>(p)); #else explain_no_incremental(_("unsupported file: 32-bit, little-endian")); #endif @@ -395,7 +400,7 @@ open_incremental_binary(Output_file* file) { #ifdef HAVE_TARGET_64_BIG result = make_sized_incremental_binary<64, true>( - file, elfcpp::Ehdr<64, true>(p)); + name, file, elfcpp::Ehdr<64, true>(p)); #else explain_no_incremental(_("unsupported file: 64-bit, big-endian")); #endif @@ -404,7 +409,7 @@ open_incremental_binary(Output_file* file) { #ifdef HAVE_TARGET_64_LITTLE result = make_sized_incremental_binary<64, false>( - file, elfcpp::Ehdr<64, false>(p)); + name, file, elfcpp::Ehdr<64, false>(p)); #else explain_no_incremental(_("unsupported file: 64-bit, little-endian")); #endif @@ -425,7 +430,8 @@ Incremental_checker::can_incrementally_link_output_file() Output_file output(this->output_name_); if (!output.open_for_modification()) return false; - Incremental_binary* binary = open_incremental_binary(&output); + Incremental_binary* binary = open_incremental_binary(this->output_name_, + &output); if (binary == NULL) return false; return binary->check_inputs(this->incremental_inputs_); diff --git a/gold/incremental.h b/gold/incremental.h index f6e36fa..706e562 100644 --- a/gold/incremental.h +++ b/gold/incremental.h @@ -220,7 +220,7 @@ class Sized_incremental_binary : public Incremental_binary // Create an Incremental_binary object for FILE. Returns NULL is this is not // possible, e.g. FILE is not an ELF file or has an unsupported target. Incremental_binary* -open_incremental_binary(Output_file* file); +open_incremental_binary(const std::string& name, Output_file* file); // Code invoked early during an incremental link that checks what files need // to be relinked.