summaryrefslogtreecommitdiff
path: root/gold/incremental.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2011-04-05 20:16:17 +0000
committerCary Coutant <ccoutant@google.com>2011-04-05 20:16:17 +0000
commitb961d0d7b65a2bdfd465f774db948c199fddaa06 (patch)
treefac883ba6bfa4b2a6bb87a79326f3b5747590140 /gold/incremental.cc
parenta869183fab276723f2f7eb55af604e106007285f (diff)
* incremental-dump.cc (dump_incremental_inputs): Change signature
to take a Sized_incremental_binary; change caller. Use readers in Sized_incremental_binary. * incremental.cc (Sized_incremental_binary::find_incremental_inputs_sections): Rename do_find_incremental_inputs_sections to this. (Sized_incremental_binary::setup_readers): New function. (Sized_incremental_binary::do_check_inputs): Check has_incremental_info_ flag; move setup code to setup_readers; use input readers. (Sized_incremental_binary::do_file_is_unchanged): New function. (Sized_incremental_binary::do_get_input_reader): New function. * incremental.h (class Incremental_binary): Move to end of file. (Incremental_binary::file_is_unchanged): New function. (Incremental_binary::do_file_is_unchanged): New function. (Incremental_binary::Input_reader): New class. (Incremental_binary::get_input_reader): New function. (class Sized_incremental_binary): Move to end of file. (Sized_incremental_binary::Sized_incremental_binary): Setup the input section reader classes. (Sized_incremental_binary::has_incremental_info): New function. (Sized_incremental_binary::inputs_reader): New function. (Sized_incremental_binary::symtab_reader): New function. (Sized_incremental_binary::relocs_reader): New function. (Sized_incremental_binary::got_plt_reader): New function. (Sized_incremental_binary::do_file_is_unchanged): New function. (Sized_incremental_binary::Sized_input_reader): New class. (Sized_incremental_binary::get_input_reader): New function. (Sized_incremental_binary::find_incremental_inputs_sections): Rename do_find_incremental_inputs_sections to this. (Sized_incremental_binary::setup_readers): New function. (Sized_incremental_binary::has_incremental_info_): New data member. (Sized_incremental_binary::inputs_reader_): New data member. (Sized_incremental_binary::symtab_reader_): New data member. (Sized_incremental_binary::relocs_reader_): New data member. (Sized_incremental_binary::got_plt_reader_): New data member. (Sized_incremental_binary::current_input_file_): New data member.
Diffstat (limited to 'gold/incremental.cc')
-rw-r--r--gold/incremental.cc96
1 files changed, 72 insertions, 24 deletions
diff --git a/gold/incremental.cc b/gold/incremental.cc
index e5f71f5ed6..a38b12b6cd 100644
--- a/gold/incremental.cc
+++ b/gold/incremental.cc
@@ -154,7 +154,7 @@ Incremental_binary::error(const char* format, ...) const
template<int size, bool big_endian>
bool
-Sized_incremental_binary<size, big_endian>::do_find_incremental_inputs_sections(
+Sized_incremental_binary<size, big_endian>::find_incremental_inputs_sections(
unsigned int* p_inputs_shndx,
unsigned int* p_symtab_shndx,
unsigned int* p_relocs_shndx,
@@ -206,60 +206,108 @@ Sized_incremental_binary<size, big_endian>::do_find_incremental_inputs_sections(
return true;
}
-// Determine whether an incremental link based on the existing output file
-// can be done.
+// Set up the readers into the incremental info sections.
template<int size, bool big_endian>
-bool
-Sized_incremental_binary<size, big_endian>::do_check_inputs(
- Incremental_inputs* incremental_inputs)
+void
+Sized_incremental_binary<size, big_endian>::setup_readers()
{
unsigned int inputs_shndx;
unsigned int symtab_shndx;
unsigned int relocs_shndx;
- unsigned int plt_got_shndx;
+ unsigned int got_plt_shndx;
unsigned int strtab_shndx;
- if (!do_find_incremental_inputs_sections(&inputs_shndx, &symtab_shndx,
- &relocs_shndx, &plt_got_shndx,
- &strtab_shndx))
- {
- explain_no_incremental(_("no incremental data from previous build"));
- return false;
- }
+ if (!this->find_incremental_inputs_sections(&inputs_shndx, &symtab_shndx,
+ &relocs_shndx, &got_plt_shndx,
+ &strtab_shndx))
+ return;
Location inputs_location(this->elf_file_.section_contents(inputs_shndx));
Location symtab_location(this->elf_file_.section_contents(symtab_shndx));
Location relocs_location(this->elf_file_.section_contents(relocs_shndx));
+ Location got_plt_location(this->elf_file_.section_contents(got_plt_shndx));
Location strtab_location(this->elf_file_.section_contents(strtab_shndx));
- View inputs_view(view(inputs_location));
- View symtab_view(view(symtab_location));
- View relocs_view(view(relocs_location));
- View strtab_view(view(strtab_location));
+ View inputs_view = this->view(inputs_location);
+ View symtab_view = this->view(symtab_location);
+ View relocs_view = this->view(relocs_location);
+ View got_plt_view = this->view(got_plt_location);
+ View strtab_view = this->view(strtab_location);
elfcpp::Elf_strtab strtab(strtab_view.data(), strtab_location.data_size);
- Incremental_inputs_reader<size, big_endian>
- incoming_inputs(inputs_view.data(), strtab);
+ this->inputs_reader_ =
+ Incremental_inputs_reader<size, big_endian>(inputs_view.data(), strtab);
+ this->symtab_reader_ =
+ Incremental_symtab_reader<big_endian>(symtab_view.data(),
+ symtab_location.data_size);
+ this->relocs_reader_ =
+ Incremental_relocs_reader<size, big_endian>(relocs_view.data(),
+ relocs_location.data_size);
+ this->got_plt_reader_ =
+ Incremental_got_plt_reader<big_endian>(got_plt_view.data());
+ this->has_incremental_info_ = true;
+}
+
+// Determine whether an incremental link based on the existing output file
+// can be done.
+
+template<int size, bool big_endian>
+bool
+Sized_incremental_binary<size, big_endian>::do_check_inputs(
+ Incremental_inputs* incremental_inputs)
+{
+ if (!this->has_incremental_info_)
+ {
+ explain_no_incremental(_("no incremental data from previous build"));
+ return false;
+ }
- if (incoming_inputs.version() != INCREMENTAL_LINK_VERSION)
+ if (this->inputs_reader_.version() != INCREMENTAL_LINK_VERSION)
{
explain_no_incremental(_("different version of incremental build data"));
return false;
}
- if (incremental_inputs->command_line() != incoming_inputs.command_line())
+ if (incremental_inputs->command_line() != this->inputs_reader_.command_line())
{
explain_no_incremental(_("command line changed"));
return false;
}
- // TODO: compare incremental_inputs->inputs() with entries in data_view.
-
return true;
}
+// Return TRUE if the file specified by INPUT_ARGUMENT is unchanged
+// with respect to the base file.
+
+template<int size, bool big_endian>
+bool
+Sized_incremental_binary<size, big_endian>::do_file_is_unchanged(
+ const Input_argument* input_argument) const
+{
+ Incremental_disposition disp =
+ input_argument->file().options().incremental_disposition();
+
+ if (disp != INCREMENTAL_CHECK)
+ return disp == INCREMENTAL_UNCHANGED;
+
+ // FIXME: Handle INCREMENTAL_CHECK.
+ return false;
+}
+
+
+template<int size, bool big_endian>
+Incremental_binary::Input_reader*
+Sized_incremental_binary<size, big_endian>::do_get_input_reader(
+ const char*)
+{
+ unsigned int file_index = this->current_input_file_++;
+ gold_assert(file_index < this->inputs_reader_.input_file_count());
+ return new Sized_input_reader(this->inputs_reader_.input_file(file_index));
+}
+
namespace
{