From 1fb1d64f4a7c817f91a164dc22d5a22a0e75c1b8 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 13 Oct 2020 05:08:25 -0700 Subject: [PATCH] Gold: Skip zero-sized sections for ICF 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 | 4 ++++ gold/icf.cc | 2 ++ 2 files changed, 6 insertions(+) diff --git a/gold/ChangeLog b/gold/ChangeLog index 25248a6267a..0300722c3a6 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,7 @@ +2020-10-13 H.J. Lu + + * icf.cc (Icf::find_identical_sections): Skip zero-sized sections. + 2020-10-09 Alan Modra * powerpc.cc (Powerpc_relobj::do_relocate_sections): Don't do diff --git a/gold/icf.cc b/gold/icf.cc index a60db7abc8d..54af4126696 100644 --- a/gold/icf.cc +++ b/gold/icf.cc @@ -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)) { -- 2.30.2