From 99e5bff2f9e0ccdba7d78f431f177d8f83871ddd Mon Sep 17 00:00:00 2001 From: Doug Kwan Date: Tue, 12 Jan 2010 07:22:56 +0000 Subject: 2010-01-11 Doug Kwan * arm.cc (Arm_relobj::do_gc_process_relocs): New method. (Target_arm::do_finalize_sections): Define special EXIDX section symbols only if referenced. * gc.h (Garbage_collection::add_reference): New method. (gc_process_relocs): Use Garbage_collection::add_reference to avoid code duplication. --- gold/gc.h | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'gold/gc.h') diff --git a/gold/gc.h b/gold/gc.h index 838b7db..3885d1a 100644 --- a/gold/gc.h +++ b/gold/gc.h @@ -108,6 +108,21 @@ class Garbage_collection Section_id secn) { this->cident_sections_[section_name].insert(secn); } + // Add a reference from the SRC_SHNDX-th section of SRC_OBJECT to + // DST_SHNDX-th section of DST_OBJECT. + void + add_reference(Object* src_object, unsigned int src_shndx, + Object* dst_object, unsigned int dst_shndx) + { + Section_id src_id(src_object, src_shndx); + Section_id dst_id(dst_object, dst_shndx); + Section_ref::iterator p = this->section_reloc_map_.find(src_id); + if (p == this->section_reloc_map_.end()) + this->section_reloc_map_[src_id].insert(dst_id); + else + p->second.insert(dst_id); + } + private: Worklist_type work_list_; @@ -261,25 +276,14 @@ gc_process_relocs( } if (parameters->options().gc_sections()) { - Section_id src_id(src_obj, src_indx); - Section_id dst_id(dst_obj, dst_indx); - Garbage_collection::Section_ref::iterator map_it; - map_it = symtab->gc()->section_reloc_map().find(src_id); - if (map_it == symtab->gc()->section_reloc_map().end()) - { - symtab->gc()->section_reloc_map()[src_id].insert(dst_id); - } - else - { - Garbage_collection::Sections_reachable& v(map_it->second); - v.insert(dst_id); - } + symtab->gc()->add_reference(src_obj, src_indx, dst_obj, dst_indx); if (cident_section_name != NULL) { Garbage_collection::Cident_section_map::iterator ele = symtab->gc()->cident_sections()->find(std::string(cident_section_name)); if (ele == symtab->gc()->cident_sections()->end()) continue; + Section_id src_id(src_obj, src_indx); Garbage_collection::Sections_reachable& v(symtab->gc()->section_reloc_map()[src_id]); Garbage_collection::Sections_reachable& cident_secn(ele->second); -- cgit v1.1