diff options
author | Ian Lance Taylor <ian@airs.com> | 2008-05-21 21:37:44 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2008-05-21 21:37:44 +0000 |
commit | 7d9e3d985416edccb274f0c704901839234cf4a9 (patch) | |
tree | 967f5b9545762a0a2ed3cabf4a2e0e4fb1fd6fd3 /gold/output.h | |
parent | 9f61f19bbf80ed99be35a8e482b914eabca1b3d8 (diff) | |
download | gdb-7d9e3d985416edccb274f0c704901839234cf4a9.zip gdb-7d9e3d985416edccb274f0c704901839234cf4a9.tar.gz gdb-7d9e3d985416edccb274f0c704901839234cf4a9.tar.bz2 |
* mapfile.cc: New file.
* mapfile.h: New file.
* options.h (class General_options): Add -M/--print-map and -Map.
* options.cc (General_options::finalize): Make -M equivalent to
-Map -.
* main.cc: Include <cstdio> and "mapfile.h".
(main): Open mapfile if requested.
* gold.cc (class Middle_runner): Add mapfile_ field. Update
constructor. Change caller.
(queue_initial_tasks): Add mapfile parameter. Change caller.
(queue_middle_tasks): Likewise.
* gold.h (queue_initial_tasks, queue_middle_tasks): Update
declarations.
* archive.cc: Include "mapfile.h".
(Archive::add_symbols): Add mapfile parameter. Change all
callers. Pass mapfile, symbol, and reason to include_member.
(Archive::include_all_members): Add mapfile parameter. Change all
callers.
(Archive::include_member): Add mapfile, sym, and why parameters.
Change all callers. Report inclusion to map file.
* archive.h: Include "fileread.h".
(class Archive): Update declarations.
(Archive::file): New const method.
(class Add_archive_symbols): Add mapfile_ field. Update
constructor. Change all callers.
* readsyms.h (class Read_symbols): Likewise.
(class Finish_group): Likewise.
(class Read_script): Likewise.
* common.cc: Include "mapfile.h".
(Symbol_table::allocate_commons): Add mapfile parameter. Change
all callers.
(Symbol_table::do_allocate_commons): Likewise.
(Symbol_table::do_allocate_commons_list): Likewise. Report common
symbol allocation to mapfile.
* common.h (class Allocate_commons_task): Add mapfile_ field.
Update constructor. Change all callers.
* symtab.h (class Symbol_table): Update declarations.
* layout.cc: Include "mapfile.h".
(Layout_task_runner::run): Print information to mapfile.
(Layout::create_gold_note): Change Output_data_fixed_space to
Output_data_zero_fill.
(Layout::create_build_id): Likewise.
(Layout::print_to_mapfile): New function.
* layout.h (class Layout_task_runner): Add mapfile_ field. Update
constructor. Change caller.
(class Layout): Declare print_to_mapfile.
* output.cc (Output_section::Input_section::print_to_mapfile): New
function.
(Output_section::add_input_section): If producing a map, always
add to input_sections_ list.
(Output_section::do_print_to_mapfile): New function.
(Output_segment::print_sections_to_mapfile): New function.
(Output_segment::print_section_list_to_mapfile): New function.
* output.h: Include "mapfile.h".
(Output_data::print_to_mapfile): New function.
(Output_data::do_print_to_mapfile): New virtual function.
(Output_segment_headers::do_print_to_mapfile): New function.
(Output_file_header::do_print_to_mapfile): New function.
(Output_data_const::do_print_to_mapfile): New function.
(class Output_data_const_buffer): Add map_name_ field. Update
constructor. Change all callers. Add do_print_to_mapfile
function.
(class Output_data_fixed_space): Likewise.
(class Output_data_space): Likewise.
(class Output_data_zero_fill): New class.
(Output_data_strtab::do_print_to_mapfile): New function.
(Output_data_reloc_base::do_print_to_mapfile): New function.
(Output_relocatable_relocs::do_print_to_mapfile): New function.
(Output_data_group::do_print_to_mapfile): New function.
(Output_data_got::do_print_to_mapfile): New function.
(Output_data_dynamic::do_print_to_mapfile): New function.
(Output_symtab_xindex::do_print_to_mapfile): New function.
(class Output_section): Declare do_print_to_mapflie. Declare
print_to_mapfile in Input_section.
(class Output_segment): Declare new functions.
* object.h (Sized_relobj::symbol_count): New function.
* script-sections.cc
(Output_section_element_dot_assignment::set_section_addresses):
Change Output_data_fixed_space to Output_data_zero_fill.
(Output_data_expression::do_print_to_mapfile): New function.
* script.cc (read_input_script): Add mapfile parameter. Change
all callers.
* script.h (read_input_script): Update declaration.
* ehframe.h (Eh_frame_hdr::do_print_to_mapfile): New function.
(Eh_frame::do_print_to_mapfile): New function.
* merge.h (Output_merge_data::do_print_to_mapfile): New function.
(Output_merge_string::do_print_to_mapfile): New function.
* i386.cc (Output_data_plt_i386::do_print_to_mapfile): New
function.
* sparc.cc (Output_data_plt_sparc::do_print_to_mapfile): New
function.
* x86_64.cc (Output_data_plt_x86_64::do_print_to_mapfile): New
function.
* Makefile.am (CCFILES): Add mapfile.cc.
(HFILES): Add mapfile.h.
* Makefile.in: Rebuild.
Diffstat (limited to 'gold/output.h')
-rw-r--r-- | gold/output.h | 155 |
1 files changed, 149 insertions, 6 deletions
diff --git a/gold/output.h b/gold/output.h index a8f2f39..dceaceb 100644 --- a/gold/output.h +++ b/gold/output.h @@ -27,6 +27,7 @@ #include <vector> #include "elfcpp.h" +#include "mapfile.h" #include "layout.h" #include "reloc-types.h" @@ -240,6 +241,11 @@ class Output_data is_data_size_valid() const { return this->is_data_size_valid_; } + // Print information to the map file. + void + print_to_mapfile(Mapfile* mapfile) const + { return this->do_print_to_mapfile(mapfile); } + protected: // Functions that child classes may or in some cases must implement. @@ -316,6 +322,12 @@ class Output_data do_tls_offset() const { gold_unreachable(); } + // Print to the map file. This only needs to be implemented by + // classes which may appear in a PT_LOAD segment. + virtual void + do_print_to_mapfile(Mapfile*) const + { gold_unreachable(); } + // Functions that child classes may call. // Set the size of the data. @@ -397,6 +409,11 @@ class Output_section_headers : public Output_data do_addralign() const { return Output_data::default_alignment(); } + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** section headers")); } + private: // Write the data to the file with the right size and endianness. template<int size, bool big_endian> @@ -428,6 +445,11 @@ class Output_segment_headers : public Output_data do_addralign() const { return Output_data::default_alignment(); } + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** segment headers")); } + private: // Write the data to the file with the right size and endianness. template<int size, bool big_endian> @@ -462,6 +484,11 @@ class Output_file_header : public Output_data do_addralign() const { return Output_data::default_alignment(); } + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** file header")); } + private: // Write the data to the file with the right size and endianness. template<int size, bool big_endian> @@ -663,6 +690,11 @@ class Output_data_const : public Output_section_data do_write_to_buffer(unsigned char* buffer) { memcpy(buffer, this->data_.data(), this->data_.size()); } + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** fill")); } + private: std::string data_; }; @@ -674,8 +706,9 @@ class Output_data_const_buffer : public Output_section_data { public: Output_data_const_buffer(const unsigned char* p, off_t len, - uint64_t addralign) - : Output_section_data(len, addralign), p_(p) + uint64_t addralign, const char* map_name) + : Output_section_data(len, addralign), + p_(p), map_name_(map_name) { } protected: @@ -688,8 +721,17 @@ class Output_data_const_buffer : public Output_section_data do_write_to_buffer(unsigned char* buffer) { memcpy(buffer, this->p_, this->data_size()); } + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _(this->map_name_)); } + private: + // The data to output. const unsigned char* p_; + // Name to use in a map file. Maps are a rarely used feature, but + // the space usage is minor as aren't very many of these objects. + const char* map_name_; }; // A place holder for a fixed amount of data written out via some @@ -698,8 +740,10 @@ class Output_data_const_buffer : public Output_section_data class Output_data_fixed_space : public Output_section_data { public: - Output_data_fixed_space(off_t data_size, uint64_t addralign) - : Output_section_data(data_size, addralign) + Output_data_fixed_space(off_t data_size, uint64_t addralign, + const char* map_name) + : Output_section_data(data_size, addralign), + map_name_(map_name) { } protected: @@ -708,6 +752,16 @@ class Output_data_fixed_space : public Output_section_data void do_write(Output_file*) { } + + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _(this->map_name_)); } + + private: + // Name to use in a map file. Maps are a rarely used feature, but + // the space usage is minor as aren't very many of these objects. + const char* map_name_; }; // A place holder for variable sized data written out via some other @@ -716,8 +770,9 @@ class Output_data_fixed_space : public Output_section_data class Output_data_space : public Output_section_data_build { public: - explicit Output_data_space(uint64_t addralign) - : Output_section_data_build(addralign) + explicit Output_data_space(uint64_t addralign, const char* map_name) + : Output_section_data_build(addralign), + map_name_(map_name) { } // Set the alignment. @@ -731,6 +786,38 @@ class Output_data_space : public Output_section_data_build void do_write(Output_file*) { } + + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _(this->map_name_)); } + + private: + // Name to use in a map file. Maps are a rarely used feature, but + // the space usage is minor as aren't very many of these objects. + const char* map_name_; +}; + +// Fill fixed space with zeroes. This is just like +// Output_data_fixed_space, except that the map name is known. + +class Output_data_zero_fill : public Output_section_data +{ + public: + Output_data_zero_fill(off_t data_size, uint64_t addralign) + : Output_section_data(data_size, addralign) + { } + + protected: + // There is no data to write out. + void + do_write(Output_file*) + { } + + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, "** zero fill"); } }; // A string table which goes into an output section. @@ -757,6 +844,11 @@ class Output_data_strtab : public Output_section_data do_write_to_buffer(unsigned char* buffer) { this->strtab_->write_to_buffer(buffer, this->data_size()); } + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** string table")); } + private: Stringpool* strtab_; }; @@ -1056,6 +1148,16 @@ class Output_data_reloc_base : public Output_section_data_build void do_adjust_output_section(Output_section *os); + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { + mapfile->print_output_data(this, + (dynamic + ? _("** dynamic relocs") + : _("** relocs"))); + } + // Add a relocation entry. void add(Output_data *od, const Output_reloc_type& reloc) @@ -1380,6 +1482,11 @@ class Output_relocatable_relocs : public Output_section_data do_write(Output_file*) { } + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** relocs")); } + private: // The relocs associated with this input section. Relocatable_relocs* rr_; @@ -1400,6 +1507,11 @@ class Output_data_group : public Output_section_data void do_write(Output_file*); + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** group")); } + private: // The input object. Sized_relobj<size, big_endian>* relobj_; @@ -1502,6 +1614,11 @@ class Output_data_got : public Output_section_data_build void do_write(Output_file*); + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** GOT")); } + private: // This POD class holds a single GOT entry. class Got_entry @@ -1639,6 +1756,11 @@ class Output_data_dynamic : public Output_section_data void do_write(Output_file*); + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** dynamic")); } + private: // This POD class holds a single dynamic entry. class Dynamic_entry @@ -1752,6 +1874,11 @@ class Output_symtab_xindex : public Output_section_data void do_write(Output_file*); + // Write to a map file. + void + do_print_to_mapfile(Mapfile* mapfile) const + { mapfile->print_output_data(this, _("** symtab xindex")); } + private: template<bool big_endian> void @@ -2262,6 +2389,10 @@ class Output_section : public Output_data do_finalize_name(Layout*) { } + // Print to the map file. + virtual void + do_print_to_mapfile(Mapfile*) const; + // Record that this section requires postprocessing after all // relocations have been applied. This is called by a child class. void @@ -2439,6 +2570,10 @@ class Output_section : public Output_data void write_to_buffer(unsigned char*); + // Print to a map file. + void + print_to_mapfile(Mapfile*) const; + // Print statistics about merge sections to stderr. void print_merge_stats(const char* section_name) @@ -2802,6 +2937,10 @@ class Output_segment write_section_headers(const Layout*, const Stringpool*, unsigned char* v, unsigned int* pshndx) const; + // Print the output sections in the map file. + void + print_sections_to_mapfile(Mapfile*) const; + private: Output_segment(const Output_segment&); Output_segment& operator=(const Output_segment&); @@ -2844,6 +2983,10 @@ class Output_segment const Output_data_list*, unsigned char* v, unsigned int* pshdx) const; + // Print a section list to the mapfile. + void + print_section_list_to_mapfile(Mapfile*, const Output_data_list*) const; + // The list of output data with contents attached to this segment. Output_data_list output_data_; // The list of output data without contents attached to this segment. |