aboutsummaryrefslogtreecommitdiff
path: root/gold/output.cc
diff options
context:
space:
mode:
authorDoug Kwan <dougkwan@google.com>2010-04-09 00:04:30 +0000
committerDoug Kwan <dougkwan@google.com>2010-04-09 00:04:30 +0000
commit6bf924b0ab37b8fd62d11262e93f34902ed5e457 (patch)
tree8ffd987c75364592ecd5eb45c4192ec315bbaba6 /gold/output.cc
parent1c1955e56553851937da2034da6a4ca9f07688aa (diff)
downloadgdb-6bf924b0ab37b8fd62d11262e93f34902ed5e457.zip
gdb-6bf924b0ab37b8fd62d11262e93f34902ed5e457.tar.gz
gdb-6bf924b0ab37b8fd62d11262e93f34902ed5e457.tar.bz2
2010-04-08 Doug Kwan <dougkwan@google.com>
* merge.cc (Output_merge_data::set_final_data_size): Handle empty Output_merge_data. * output.cc (Output_section::add_merge_input_section): Simplify code and return status of Output_merge_base::add_input_section. Update merge section map only if Output_merge_base::add_input_section returns true.
Diffstat (limited to 'gold/output.cc')
-rw-r--r--gold/output.cc77
1 files changed, 37 insertions, 40 deletions
diff --git a/gold/output.cc b/gold/output.cc
index 0627cbe..37ec8b3 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -2154,58 +2154,55 @@ Output_section::add_merge_input_section(Relobj* object, unsigned int shndx,
gold_assert(this->checkpoint_ == NULL);
// Look up merge sections by required properties.
+ Output_merge_base* pomb;
Merge_section_properties msp(is_string, entsize, addralign);
Merge_section_by_properties_map::const_iterator p =
this->merge_section_by_properties_map_.find(msp);
if (p != this->merge_section_by_properties_map_.end())
{
- Output_merge_base* merge_section = p->second;
- merge_section->add_input_section(object, shndx);
- gold_assert(merge_section->is_string() == is_string
- && merge_section->entsize() == entsize
- && merge_section->addralign() == addralign);
-
- // Link input section to found merge section.
- Const_section_id csid(object, shndx);
- this->merge_section_map_[csid] = merge_section;
- return true;
+ pomb = p->second;
+ gold_assert(pomb->is_string() == is_string
+ && pomb->entsize() == entsize
+ && pomb->addralign() == addralign);
}
-
- // We handle the actual constant merging in Output_merge_data or
- // Output_merge_string_data.
- Output_merge_base* pomb;
- if (!is_string)
- pomb = new Output_merge_data(entsize, addralign);
else
{
- switch (entsize)
+ // Create a new Output_merge_data or Output_merge_string_data.
+ if (!is_string)
+ pomb = new Output_merge_data(entsize, addralign);
+ else
{
- case 1:
- pomb = new Output_merge_string<char>(addralign);
- break;
- case 2:
- pomb = new Output_merge_string<uint16_t>(addralign);
- break;
- case 4:
- pomb = new Output_merge_string<uint32_t>(addralign);
- break;
- default:
- return false;
+ switch (entsize)
+ {
+ case 1:
+ pomb = new Output_merge_string<char>(addralign);
+ break;
+ case 2:
+ pomb = new Output_merge_string<uint16_t>(addralign);
+ break;
+ case 4:
+ pomb = new Output_merge_string<uint32_t>(addralign);
+ break;
+ default:
+ return false;
+ }
}
+ // Add new merge section to this output section and link merge
+ // section properties to new merge section in map.
+ this->add_output_merge_section(pomb, is_string, entsize);
+ this->merge_section_by_properties_map_[msp] = pomb;
}
- // Add new merge section to this output section and link merge section
- // properties to new merge section in map.
- this->add_output_merge_section(pomb, is_string, entsize);
- this->merge_section_by_properties_map_[msp] = pomb;
-
- // Add input section to new merge section and link input section to new
- // merge section in map.
- pomb->add_input_section(object, shndx);
- Const_section_id csid(object, shndx);
- this->merge_section_map_[csid] = pomb;
-
- return true;
+ if (pomb->add_input_section(object, shndx))
+ {
+ // Add input section to new merge section and link input section to new
+ // merge section in map.
+ Const_section_id csid(object, shndx);
+ this->merge_section_map_[csid] = pomb;
+ return true;
+ }
+ else
+ return false;
}
// Build a relaxation map to speed up relaxation of existing input sections.