aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-05-21 21:37:44 +0000
committerIan Lance Taylor <ian@airs.com>2008-05-21 21:37:44 +0000
commit7d9e3d985416edccb274f0c704901839234cf4a9 (patch)
tree967f5b9545762a0a2ed3cabf4a2e0e4fb1fd6fd3 /gold/layout.cc
parent9f61f19bbf80ed99be35a8e482b914eabca1b3d8 (diff)
downloadgdb-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/layout.cc')
-rw-r--r--gold/layout.cc53
1 files changed, 38 insertions, 15 deletions
diff --git a/gold/layout.cc b/gold/layout.cc
index eae6679..a4003d5 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -35,6 +35,7 @@
#include "parameters.h"
#include "options.h"
+#include "mapfile.h"
#include "script.h"
#include "script-sections.h"
#include "output.h"
@@ -63,6 +64,13 @@ Layout_task_runner::run(Workqueue* workqueue, const Task* task)
// Now we know the final size of the output file and we know where
// each piece of information goes.
+
+ if (this->mapfile_ != NULL)
+ {
+ this->mapfile_->print_discarded_sections(this->input_objects_);
+ this->layout_->print_to_mapfile(this->mapfile_);
+ }
+
Output_file* of = new Output_file(parameters->options().output_file_name());
if (this->options_.oformat_enum() != General_options::OBJECT_FORMAT_ELF)
of->set_is_temporary();
@@ -1323,7 +1331,8 @@ Layout::create_note(const char* name, int note_type, size_t descsz,
elfcpp::SHT_NOTE,
flags);
Output_section_data* posd = new Output_data_const_buffer(buffer, notehdrsz,
- size / 8);
+ size / 8,
+ "** note header");
os->add_output_section_data(posd);
*trailing_padding = aligned_descsz - descsz;
@@ -1351,7 +1360,7 @@ Layout::create_gold_note()
if (trailing_padding > 0)
{
- posd = new Output_data_fixed_space(trailing_padding, 0);
+ posd = new Output_data_zero_fill(trailing_padding, 0);
os->add_output_section_data(posd);
}
}
@@ -1488,7 +1497,7 @@ Layout::create_build_id()
if (trailing_padding != 0)
{
- posd = new Output_data_fixed_space(trailing_padding, 0);
+ posd = new Output_data_zero_fill(trailing_padding, 0);
os->add_output_section_data(posd);
}
}
@@ -1497,7 +1506,7 @@ Layout::create_build_id()
// We need to compute a checksum after we have completed the
// link.
gold_assert(trailing_padding == 0);
- this->build_id_note_ = new Output_data_fixed_space(descsz, 4);
+ this->build_id_note_ = new Output_data_zero_fill(descsz, 4);
os->add_output_section_data(this->build_id_note_);
os->set_after_input_sections();
}
@@ -2049,7 +2058,8 @@ Layout::create_symtab_sections(const Input_objects* input_objects,
this->symtab_section_ = osymtab;
Output_section_data* pos = new Output_data_fixed_space(off - startoff,
- align);
+ align,
+ "** symtab");
osymtab->add_output_section_data(pos);
// We generate a .symtab_shndx section if we have more than
@@ -2230,7 +2240,8 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects,
false);
Output_section_data* odata = new Output_data_fixed_space(index * symsize,
- align);
+ align,
+ "** dynsym");
dynsym->add_output_section_data(odata);
dynsym->set_info(local_symcount);
@@ -2309,7 +2320,8 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects,
Output_section_data* hashdata = new Output_data_const_buffer(phash,
hashlen,
- align);
+ align,
+ "** hash");
hashsec->add_output_section_data(hashdata);
hashsec->set_link_section(dynsym);
@@ -2333,7 +2345,8 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects,
Output_section_data* hashdata = new Output_data_const_buffer(phash,
hashlen,
- align);
+ align,
+ "** hash");
hashsec->add_output_section_data(hashdata);
hashsec->set_link_section(dynsym);
@@ -2435,7 +2448,8 @@ Layout::sized_create_version_sections(
dynamic_symbols,
&vbuf, &vsize);
- Output_section_data* vdata = new Output_data_const_buffer(vbuf, vsize, 2);
+ Output_section_data* vdata = new Output_data_const_buffer(vbuf, vsize, 2,
+ "** versions");
vsec->add_output_section_data(vdata);
vsec->set_entsize(2);
@@ -2458,9 +2472,8 @@ Layout::sized_create_version_sections(
versions->def_section_contents<size, big_endian>(&this->dynpool_, &vdbuf,
&vdsize, &vdentries);
- Output_section_data* vddata = new Output_data_const_buffer(vdbuf,
- vdsize,
- 4);
+ Output_section_data* vddata =
+ new Output_data_const_buffer(vdbuf, vdsize, 4, "** version defs");
vdsec->add_output_section_data(vddata);
vdsec->set_link_section(dynstr);
@@ -2485,9 +2498,8 @@ Layout::sized_create_version_sections(
&vnbuf, &vnsize,
&vnentries);
- Output_section_data* vndata = new Output_data_const_buffer(vnbuf,
- vnsize,
- 4);
+ Output_section_data* vndata =
+ new Output_data_const_buffer(vnbuf, vnsize, 4, "** version refs");
vnsec->add_output_section_data(vndata);
vnsec->set_link_section(dynstr);
@@ -3086,6 +3098,17 @@ Layout::write_binary(Output_file* in) const
out.close();
}
+// Print the output sections to the map file.
+
+void
+Layout::print_to_mapfile(Mapfile* mapfile) const
+{
+ for (Segment_list::const_iterator p = this->segment_list_.begin();
+ p != this->segment_list_.end();
+ ++p)
+ (*p)->print_sections_to_mapfile(mapfile);
+}
+
// Print statistical information to stderr. This is used for --stats.
void