From 6625d24e236a525781fda9482af925ade7f60c97 Mon Sep 17 00:00:00 2001 From: Doug Kwan Date: Wed, 19 May 2010 07:09:36 +0000 Subject: 2010-05-14 Doug Kwan * arm.cc (Arm_input_section::original_size): New method. (Arm_input_section::do_addralign): Add a cast. (Arm_input_section::do_output_offset): Remove static cast. (Arm_input_section::original_addralign, Arm_input_section::original_size_): Change type to uint32_t. (Arm_input_section::init): Add safe casts for section alignment and size. (Arm_input_section::set_final_data_size): Do not set address and offset of stub table. (Arm_output_section::fix_exidx_coverage): Change use of of Output_section::Simple_input_section to that of Output_section::Input_section. (Target_arm::do_relax): Set addresses and file offsets of Stub_tables except for the first pass. * output.cc (Output_section::get_input_sections): Change type of input_sections to std::list. (Output_section::add_script_input_section): Rename from Output_section::add_simple_input_section. Change type of SIS parameter from Simple_input_section to Input_section. * output.h (Output_section::Simple_input_section): Remove class. (Output_section::Input_section): Change class visibility to public. (Output_section::Input_section::addralign): Use stored alignments for special input sections if set. (Output_section::Input_section::set_addralign): New method. (Output_section::get_input_sections): Change parameter type from list of Simple_input_section to list of Input_section. (Output_section::add_script_input_section): Rename from Output_section::add_simple_input_section. Change first parameter's type from Simple_input_section to Input_section and remove the second and third parameters. * script-sections.cc (Input_section::Input_section_list): Change type to list of Output_section::Input_section/ (Input_section_info::Input_section_info): Change parameter type of INPUT_SECTION to Output_section::Input_section. (Input_section_info::input_section): Change return type. (Input_section_info::input_section_): Change type to Output_section::Input_section. (Output_section_element_input::set_section_addresses): Adjust code to use Output_section::Input_section instead of Output_section::Simple_input_section. Adjust code for renaming of Output_section::add_simple_input_section. (Orphan_output_section::set_section_addresses): Ditto. --- gold/script-sections.cc | 55 ++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'gold/script-sections.cc') diff --git a/gold/script-sections.cc b/gold/script-sections.cc index b4cbb40..e778279 100644 --- a/gold/script-sections.cc +++ b/gold/script-sections.cc @@ -546,7 +546,7 @@ class Output_section_element { public: // A list of input sections. - typedef std::list Input_section_list; + typedef std::list Input_section_list; Output_section_element() { } @@ -1195,13 +1195,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_; } @@ -1247,7 +1247,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. @@ -1418,9 +1418,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); @@ -1434,11 +1445,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; } } @@ -2381,7 +2389,7 @@ Orphan_output_section::set_section_addresses(Symbol_table*, Layout*, uint64_t*, uint64_t* load_address) { - typedef std::list Input_section_list; + typedef std::list Input_section_list; bool have_load_address = *load_address != *dot_value; @@ -2403,25 +2411,12 @@ Orphan_output_section::set_section_addresses(Symbol_table*, Layout*, p != input_sections.end(); ++p) { - uint64_t addralign; - uint64_t size; - - // We know we are single-threaded, so it is OK to lock the - // object. - { - const Task* task = reinterpret_cast(-1); - Task_lock_obj 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; } -- cgit v1.1