Gold: Skip zero-sized sections for ICF
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 13 Oct 2020 12:08:25 +0000 (05:08 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 13 Oct 2020 12:08:39 +0000 (05:08 -0700)
Skip zero-sized sections since there is no need to do ICF on them.

* icf.cc (Icf::find_identical_sections): Skip zero-sized sections.

gold/ChangeLog
gold/icf.cc

index 25248a6267a0624b574ae570ac8a4a8d5cf8dfad..0300722c3a6eecbe879afe9f54570d6b06b1f007 100644 (file)
@@ -1,3 +1,7 @@
+2020-10-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * icf.cc (Icf::find_identical_sections): Skip zero-sized sections.
+
 2020-10-09  Alan Modra  <amodra@gmail.com>
 
        * powerpc.cc (Powerpc_relobj::do_relocate_sections): Don't do
index a60db7abc8d2fc7b7ebde167dcb90dd76d4459d7..54af4126696284b93e0629dd257e4b91247db8f1 100644 (file)
@@ -973,6 +973,8 @@ Icf::find_identical_sections(const Input_objects* input_objects,
 
       for (unsigned int i = 0; i < (*p)->shnum(); ++i)
         {
+          if ((*p)->section_size(i) == 0)
+            continue;
          const std::string section_name = (*p)->section_name(i);
           if (!is_section_foldable_candidate(section_name))
            {