darling-gdb/gold/mapfile.h
Cary Coutant ac45a351cf 2008-08-06 Cary Coutant <ccoutant@google.com>
* archive.cc (Archive::total_archives, Archive::total_members)
	(Archive::total_members_loaded): New variables.
	(Archive::setup): Add parameter.  Add option to preread
	archive symbols.
	(Archive::read_armap): Add counter.
	(Archive::get_file_and_offset): New function.
	(Archive::get_elf_object_for_member): New function.
	(Archive::read_all_symbols): New function.
	(Archive::read_symbols): New function.
	(Archive::add_symbols): Add counters.
	(Archive::include_all_members): Use armap to find members if it's
	already built.
	(Archive::include_member): Skip reading symbols if already read.
	Factored code into Archive::get_file_and_offset and
	Archive::get_elf_object_for_member.  Changed call to
	Mapfile::report_include_archive_member.
	(Archive::print_stats): New function.
	* archive.h: Declare Object and Read_symbols_data classes.
	(Archive::Archive): Add initializers for new members.
	(Archive::setup): Add parameter.
	(Archive::print_stats): New function.
	(Archive::total_archives, Archive::total_members)
	(Archive::total_members_loaded): New variables.
	(Archive::get_file_and_offset): New function.
	(Archive::get_elf_object_for_member): New function.
	(Archive::read_all_symbols): New function.
	(Archive::read_symbols): New function.
	(Archive::Archive_member): New class.
	(Archive::members_): New member.
	(Archive::num_members_): New member.
	* main.cc: Include archive.h.
	(main): Call Archive::print_stats.
	* mapfile.cc (Mapfile::report_include_archive_member): Delete
	archive parameter; member_name is now the fully-decorated name.
	* mapfile.h (Mapfile::report_include_archive_member): Likewise.
	* options.h: (General_options): Add --preread-archive-symbols option.
	* readsyms.cc (Read_symbols::do_read_symbols): Change call to
	Archive::setup.
2008-08-07 17:02:11 +00:00

114 lines
2.8 KiB
C++

// mapfile.h -- map file generation for gold -*- C++ -*-
// Copyright 2008 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// MA 02110-1301, USA.
#ifndef GOLD_MAP_H
#define GOLD_MAP_H
#include <cstdio>
#include <string>
namespace gold
{
class Archive;
class Symbol;
class Relobj;
template<int size, bool big_endian>
class Sized_relobj;
class Output_section;
class Output_data;
// This class manages map file output.
class Mapfile
{
public:
Mapfile();
~Mapfile();
// Open the map file. Return whether the open succeed.
bool
open(const char* map_filename);
// Close the map file.
void
close();
// Report that we are including a member from an archive. This is
// called by the archive reading code.
void
report_include_archive_member(const std::string& member_name,
const Symbol* sym, const char* why);
// Report allocating a common symbol.
void
report_allocate_common(const Symbol*, uint64_t symsize);
// Print discarded input sections.
void
print_discarded_sections(const Input_objects*);
// Print an output section.
void
print_output_section(const Output_section*);
// Print an input section.
void
print_input_section(Relobj*, unsigned int shndx);
// Print an Output_data.
void
print_output_data(const Output_data*, const char* name);
private:
// The space we allow for a section name.
static const size_t section_name_map_length;
// Advance to a column.
void
advance_to_column(size_t from, size_t to);
// Print the memory map header.
void
print_memory_map_header();
// Print symbols for an input section.
template<int size, bool big_endian>
void
print_input_section_symbols(const Sized_relobj<size, big_endian>*,
unsigned int shndx);
// Map file to write to.
FILE* map_file_;
// Whether we have printed the archive member header.
bool printed_archive_header_;
// Whether we have printed the allocated common header.
bool printed_common_header_;
// Whether we have printed the memory map header.
bool printed_memory_map_header_;
};
} // End namespace gold.
#endif // !defined(GOLD_MAP_H)