diff options
author | Doug Kwan <dougkwan@google.com> | 2010-01-23 01:07:59 +0000 |
---|---|---|
committer | Doug Kwan <dougkwan@google.com> | 2010-01-23 01:07:59 +0000 |
commit | 8923b24c4bde41e6a15026aa1d20493fd383066c (patch) | |
tree | dfe04658736dd194c41401949bafb2afdf47dafb /gold/output.cc | |
parent | 767acc28c194ace624485f0a907e07d1e95d4ce1 (diff) | |
download | gdb-8923b24c4bde41e6a15026aa1d20493fd383066c.zip gdb-8923b24c4bde41e6a15026aa1d20493fd383066c.tar.gz gdb-8923b24c4bde41e6a15026aa1d20493fd383066c.tar.bz2 |
2010-01-22 Doug Kwan <dougkwan@google.com>
* arm.cc (Target_arm::do_relax): Record an output section for section
offset adjustment it contains any stub table that has changed.
* layout.cc (Layout::clean_up_after_relaxation): Adjust section
offsets in an output section if necessary.
* output.cc (Output_section::Output_section): Initialize
section_offsets_need_adjustments_.
(Output_section::add_input_section_for_script): Renamed to
Output_section::add_simple_input_section.
(Output_section::save_states): Add a comment.
(Output_section::discard_states): New method defintion.
(Output_section::adjust_section_offsets): Same.
* output.h (Output_section::add_input_section_for_script): Renamed to
Output_section::add_simple_input_section.
(Output_section::discard_states): New method declaration.
(Output_section::adjust_section_offsets): Same.
(Output_section::section_offsets_need_adjustment,
Output_section::set_section_offsets_need_adjustment): New method
definitions.
(Output_section::section_offsets_need_adjustment_): New data member.
* script-sections.cc
(Output_section_element_input::set_section_address): Adjust code for
renaming of Output_section::add_input_section_for_script.
(Orphan_output_section::set_section_address): Same.
Diffstat (limited to 'gold/output.cc')
-rw-r--r-- | gold/output.cc | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/gold/output.cc b/gold/output.cc index 6374895..a8f03e7 100644 --- a/gold/output.cc +++ b/gold/output.cc @@ -1890,6 +1890,7 @@ Output_section::Output_section(const char* name, elfcpp::Elf_Word type, is_dynamic_linker_section_(false), generate_code_fills_at_write_(false), is_entsize_zero_(false), + section_offsets_need_adjustment_(false), tls_offset_(0), checkpoint_(NULL), merge_section_map_(), @@ -3043,12 +3044,12 @@ Output_section::get_input_sections( return data_size; } -// Add an input section from a script. +// Add an simple input section. void -Output_section::add_input_section_for_script(const Simple_input_section& sis, - off_t data_size, - uint64_t addralign) +Output_section::add_simple_input_section(const Simple_input_section& sis, + off_t data_size, + uint64_t addralign) { if (addralign > this->addralign_) this->addralign_ = addralign; @@ -3067,7 +3068,7 @@ Output_section::add_input_section_for_script(const Simple_input_section& sis, this->input_sections_.push_back(is); } -// +// Save states for relaxation. void Output_section::save_states() @@ -3083,6 +3084,19 @@ Output_section::save_states() } void +Output_section::discard_states() +{ + gold_assert(this->checkpoint_ != NULL); + delete this->checkpoint_; + this->checkpoint_ = NULL; + gold_assert(this->fills_.empty()); + + // Simply invalidate the relaxed input section map since we do not keep + // track of it. + this->is_relaxed_input_section_map_valid_ = false; +} + +void Output_section::restore_states() { gold_assert(this->checkpoint_ != NULL); @@ -3116,6 +3130,29 @@ Output_section::restore_states() this->is_relaxed_input_section_map_valid_ = false; } +// Update the section offsets of input sections in this. This is required if +// relaxation causes some input sections to change sizes. + +void +Output_section::adjust_section_offsets() +{ + if (!this->section_offsets_need_adjustment_) + return; + + off_t off = 0; + for (Input_section_list::iterator p = this->input_sections_.begin(); + p != this->input_sections_.end(); + ++p) + { + off = align_address(off, p->addralign()); + if (p->is_input_section()) + p->relobj()->set_section_offset(p->shndx(), off); + off += p->data_size(); + } + + this->section_offsets_need_adjustment_ = false; +} + // Print to the map file. void |