aboutsummaryrefslogtreecommitdiff
path: root/gold/incremental-dump.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-dump.cc
parenta869183fab276723f2f7eb55af604e106007285f (diff)
downloadgdb-b961d0d7b65a2bdfd465f774db948c199fddaa06.zip
gdb-b961d0d7b65a2bdfd465f774db948c199fddaa06.tar.gz
gdb-b961d0d7b65a2bdfd465f774db948c199fddaa06.tar.bz2
* 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-dump.cc')
-rw-r--r--gold/incremental-dump.cc74
1 files changed, 21 insertions, 53 deletions
diff --git a/gold/incremental-dump.cc b/gold/incremental-dump.cc
index e59b1c5..6f79f4d 100644
--- a/gold/incremental-dump.cc
+++ b/gold/incremental-dump.cc
@@ -73,48 +73,24 @@ find_input_containing_global(
template<int size, bool big_endian>
static void
dump_incremental_inputs(const char* argv0, const char* filename,
- Incremental_binary* inc)
+ Sized_incremental_binary<size, big_endian>* inc)
{
- bool t;
- unsigned int inputs_shndx;
- unsigned int isymtab_shndx;
- unsigned int irelocs_shndx;
- unsigned int igot_plt_shndx;
- unsigned int istrtab_shndx;
typedef Incremental_binary::Location Location;
typedef Incremental_binary::View View;
typedef Incremental_inputs_reader<size, big_endian> Inputs_reader;
typedef typename Inputs_reader::Incremental_input_entry_reader Entry_reader;
- // Find the .gnu_incremental_inputs, _symtab, _relocs, and _strtab sections.
-
- t = inc->find_incremental_inputs_sections(&inputs_shndx, &isymtab_shndx,
- &irelocs_shndx, &igot_plt_shndx,
- &istrtab_shndx);
- if (!t)
+ if (!inc->has_incremental_info())
{
fprintf(stderr, "%s: %s: no .gnu_incremental_inputs section\n", argv0,
filename);
exit(1);
}
- elfcpp::Elf_file<size, big_endian, Incremental_binary> elf_file(inc);
-
- // Get a view of the .gnu_incremental_inputs section.
-
- Location inputs_location(elf_file.section_contents(inputs_shndx));
- View inputs_view(inc->view(inputs_location));
-
- // Get the .gnu_incremental_strtab section as a string table.
-
- Location istrtab_location(elf_file.section_contents(istrtab_shndx));
- View istrtab_view(inc->view(istrtab_location));
- elfcpp::Elf_strtab istrtab(istrtab_view.data(), istrtab_location.data_size);
-
// Create a reader object for the .gnu_incremental_inputs section.
Incremental_inputs_reader<size, big_endian>
- incremental_inputs(inputs_view.data(), istrtab);
+ incremental_inputs(inc->inputs_reader());
if (incremental_inputs.version() != 1)
{
@@ -265,6 +241,8 @@ dump_incremental_inputs(const char* argv0, const char* filename,
// Get a view of the .symtab section.
+ elfcpp::Elf_file<size, big_endian, Incremental_binary> elf_file(inc);
+
unsigned int symtab_shndx = elf_file.find_section_by_type(elfcpp::SHT_SYMTAB);
if (symtab_shndx == elfcpp::SHN_UNDEF) // Not found.
{
@@ -288,16 +266,6 @@ dump_incremental_inputs(const char* argv0, const char* filename,
View strtab_view(inc->view(strtab_location));
elfcpp::Elf_strtab strtab(strtab_view.data(), strtab_location.data_size);
- // Get a view of the .gnu_incremental_symtab section.
-
- Location isymtab_location(elf_file.section_contents(isymtab_shndx));
- View isymtab_view(inc->view(isymtab_location));
-
- // Get a view of the .gnu_incremental_relocs section.
-
- Location irelocs_location(elf_file.section_contents(irelocs_shndx));
- View irelocs_view(inc->view(irelocs_location));
-
// The .gnu_incremental_symtab section contains entries that parallel
// the global symbols of the main symbol table. The sh_info field
// of the main symbol table's section header tells us how many global
@@ -306,15 +274,13 @@ dump_incremental_inputs(const char* argv0, const char* filename,
// use the size of the .gnu_incremental_symtab section to deduce
// the number of global symbols + forced-local symbols there are
// in the symbol table.
+ Incremental_symtab_reader<big_endian> isymtab(inc->symtab_reader());
+ Incremental_relocs_reader<size, big_endian> irelocs(inc->relocs_reader());
unsigned int sym_size = elfcpp::Elf_sizes<size>::sym_size;
unsigned int nsyms = symtab_location.data_size / sym_size;
- unsigned int nglobals = isymtab_location.data_size / 4;
+ unsigned int nglobals = isymtab.symbol_count();
unsigned int first_global = nsyms - nglobals;
unsigned const char* sym_p = symtab_view.data() + first_global * sym_size;
- unsigned const char* isym_p = isymtab_view.data();
-
- Incremental_symtab_reader<big_endian> isymtab(isymtab_view.data());
- Incremental_relocs_reader<size, big_endian> irelocs(irelocs_view.data());
printf("\nGlobal symbol table:\n");
for (unsigned int i = 0; i < nglobals; i++)
@@ -356,15 +322,9 @@ dump_incremental_inputs(const char* argv0, const char* filename,
offset = sym_info.next_offset;
}
sym_p += sym_size;
- isym_p += 4;
}
- // Get a view of the .gnu_incremental_got_plt section.
-
- Location igot_plt_location(elf_file.section_contents(igot_plt_shndx));
- View igot_plt_view(inc->view(igot_plt_location));
-
- Incremental_got_plt_reader<big_endian> igot_plt(igot_plt_view.data());
+ Incremental_got_plt_reader<big_endian> igot_plt(inc->got_plt_reader());
unsigned int ngot = igot_plt.get_got_entry_count();
unsigned int nplt = igot_plt.get_plt_entry_count();
@@ -464,22 +424,30 @@ main(int argc, char** argv)
{
#ifdef HAVE_TARGET_32_LITTLE
case Parameters::TARGET_32_LITTLE:
- dump_incremental_inputs<32, false>(argv[0], filename, inc);
+ dump_incremental_inputs<32, false>(
+ argv[0], filename,
+ static_cast<Sized_incremental_binary<32, false>*>(inc));
break;
#endif
#ifdef HAVE_TARGET_32_BIG
case Parameters::TARGET_32_BIG:
- dump_incremental_inputs<32, true>(argv[0], filename, inc);
+ dump_incremental_inputs<32, true>(
+ argv[0], filename,
+ static_cast<Sized_incremental_binary<32, true>*>(inc));
break;
#endif
#ifdef HAVE_TARGET_64_LITTLE
case Parameters::TARGET_64_LITTLE:
- dump_incremental_inputs<64, false>(argv[0], filename, inc);
+ dump_incremental_inputs<64, false>(
+ argv[0], filename,
+ static_cast<Sized_incremental_binary<64, false>*>(inc));
break;
#endif
#ifdef HAVE_TARGET_64_BIG
case Parameters::TARGET_64_BIG:
- dump_incremental_inputs<64, true>(argv[0], filename, inc);
+ dump_incremental_inputs<64, true>(
+ argv[0], filename,
+ static_cast<Sized_incremental_binary<64, true>*>(inc));
break;
#endif
default: