2009-08-05 Chao-ying Fu <fu@mips.com>
[deliverable/binutils-gdb.git] / gold / reloc.cc
index b6394a56ec9a0ca9c9d05c2b7b48151a87e59a27..0842a73ca83a78d7725a1fbf0ea9343bae6777dc 100644 (file)
@@ -65,12 +65,12 @@ Read_relocs::run(Workqueue* workqueue)
   this->object_->set_relocs_data(rd);
   this->object_->release();
 
-  // If garbage collection is desired, we must process the relocs
-  // instead of scanning the relocs as reloc processing is necessary 
-  // to determine unused sections.
-  if (parameters->options().gc_sections())
-    {  
-      workqueue->queue_next(new Gc_process_relocs(this->options_, 
+  // If garbage collection or identical comdat folding is desired, we  
+  // process the relocs first before scanning them.  Scanning of relocs is
+  // done only after garbage or identical sections is identified.
+  if (parameters->options().gc_sections() || parameters->options().icf())
+    {
+      workqueue->queue_next(new Gc_process_relocs(this->options_,
                                                   this->symtab_,
                                                   this->layout_, 
                                                   this->object_, rd,
@@ -418,7 +418,7 @@ Sized_relobj<size, big_endian>::do_scan_relocs(const General_options& options,
       // When garbage collection is on, unreferenced sections are not included
       // in the link that would have been included normally. This is known only
       // after Read_relocs hence this check has to be done again.
-      if (parameters->options().gc_sections())
+      if (parameters->options().gc_sections() || parameters->options().icf())
         {
           if (p->output_section == NULL)
             continue;
@@ -822,6 +822,10 @@ Sized_relobj<size, big_endian>::relocate_sections(
       if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
        continue;
 
+      off_t sh_size = shdr.get_sh_size();
+      if (sh_size == 0)
+       continue;
+
       unsigned int index = this->adjust_shndx(shdr.get_sh_info());
       if (index >= this->shnum())
        {
@@ -851,7 +855,6 @@ Sized_relobj<size, big_endian>::relocate_sections(
          continue;
        }
 
-      off_t sh_size = shdr.get_sh_size();
       const unsigned char* prelocs = this->get_view(shdr.get_sh_offset(),
                                                    sh_size, true, false);
 
This page took 0.027736 seconds and 4 git commands to generate.