diff options
Diffstat (limited to 'binutils-2.19/gold/script-sections.cc')
-rw-r--r-- | binutils-2.19/gold/script-sections.cc | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/binutils-2.19/gold/script-sections.cc b/binutils-2.19/gold/script-sections.cc index 99f0dbf..5cfb07c 100644 --- a/binutils-2.19/gold/script-sections.cc +++ b/binutils-2.19/gold/script-sections.cc @@ -525,7 +525,7 @@ class Output_section_element { public: // A list of input sections. - typedef std::list<Output_section::Simple_input_section> Input_section_list; + typedef std::list<Output_section::Input_section> Input_section_list; Output_section_element() { } @@ -1172,13 +1172,13 @@ Output_section_element_input::match_name(const char* file_name, class Input_section_info { public: - Input_section_info(const Output_section::Simple_input_section& input_section) + Input_section_info(const Output_section::Input_section& input_section) : input_section_(input_section), section_name_(), size_(0), addralign_(1) { } // Return the simple input section. - const Output_section::Simple_input_section& + const Output_section::Input_section& input_section() const { return this->input_section_; } @@ -1224,7 +1224,7 @@ class Input_section_info private: // Input section, can be a relaxed section. - Output_section::Simple_input_section input_section_; + Output_section::Input_section input_section_; // Name of the section. std::string section_name_; // Section size. @@ -1394,9 +1394,20 @@ Output_section_element_input::set_section_addresses( p != matching_sections[i].end(); ++p) { - uint64_t this_subalign = p->addralign(); + // Override the original address alignment if SUBALIGN is specified + // and is greater than the original alignment. We need to make a + // copy of the input section to modify the alignment. + Output_section::Input_section sis(p->input_section()); + + uint64_t this_subalign = sis.addralign(); + if (!sis.is_input_section()) + sis.output_section_data()->finalize_data_size(); + uint64_t data_size = sis.data_size(); if (this_subalign < subalign) - this_subalign = subalign; + { + this_subalign = subalign; + sis.set_addralign(subalign); + } uint64_t address = align_address(dot, this_subalign); @@ -1410,11 +1421,8 @@ Output_section_element_input::set_section_addresses( layout->new_output_section_data_from_script(posd); } - output_section->add_simple_input_section(p->input_section(), - p->size(), - this_subalign); - - dot = address + p->size(); + output_section->add_script_input_section(sis); + dot = address + data_size; } } @@ -2351,7 +2359,7 @@ Orphan_output_section::set_section_addresses(Symbol_table*, Layout*, uint64_t* dot_value, uint64_t* load_address) { - typedef std::list<Output_section::Simple_input_section> Input_section_list; + typedef std::list<Output_section::Input_section> Input_section_list; bool have_load_address = *load_address != *dot_value; @@ -2373,25 +2381,12 @@ Orphan_output_section::set_section_addresses(Symbol_table*, Layout*, p != input_sections.end(); ++p) { - uint64_t addralign; - uint64_t size; - - // We know what are single-threaded, so it is OK to lock the - // object. - { - const Task* task = reinterpret_cast<const Task*>(-1); - Task_lock_obj<Object> tl(task, p->relobj()); - addralign = p->relobj()->section_addralign(p->shndx()); - if (p->is_relaxed_input_section()) - // We use current data size because relxed section sizes may not - // have finalized yet. - size = p->relaxed_input_section()->current_data_size(); - else - size = p->relobj()->section_size(p->shndx()); - } - + uint64_t addralign = p->addralign(); + if (!p->is_input_section()) + p->output_section_data()->finalize_data_size(); + uint64_t size = p->data_size(); address = align_address(address, addralign); - this->os_->add_simple_input_section(*p, size, addralign); + this->os_->add_script_input_section(*p); address += size; } |