From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2053) id C9EC13857346; Thu, 2 Jun 2022 12:21:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9EC13857346 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ilya Leoshkevich To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: Do not add empty sections to the section map X-Act-Checkin: binutils-gdb X-Git-Author: Ilya Leoshkevich X-Git-Refname: refs/heads/master X-Git-Oldrev: a7790128481894630414213603d3e894d764f802 X-Git-Newrev: 625b6eae091709b95471eae92d42dc6bc71e6553 Message-Id: <20220602122142.C9EC13857346@sourceware.org> Date: Thu, 2 Jun 2022 12:21:42 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jun 2022 12:21:42 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D625b6eae0917= 09b95471eae92d42dc6bc71e6553 commit 625b6eae091709b95471eae92d42dc6bc71e6553 Author: Ilya Leoshkevich Date: Wed Jun 1 14:04:10 2022 +0200 gdb: Do not add empty sections to the section map =20 From: Ulrich Weigand =20 build_objfile_section_table () creates four synthetic sections per objfile, which are collected by update_section_map () and passed to std::sort (). When there are a lot of objfiles, for example, when debugging JITs, the presence of these sections slows down the sorting significantly. =20 The output of update_section_map () is used by find_pc_section (), which can never return any of these sections: their size is 0, so they cannot be accepted by bsearch_cmp (). =20 Filter them (and all the other empty sections) out in insert_section_p (), which is used only by update_section_map (). Diff: --- gdb/objfiles.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 60d8aa5cb78..4fc859f185a 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -986,7 +986,7 @@ preferred_obj_section (struct obj_section *a, struct ob= j_section *b) } =20 /* Return 1 if SECTION should be inserted into the section map. - We want to insert only non-overlay and non-TLS section. */ + We want to insert only non-overlay non-TLS non-empty sections. */ =20 static int insert_section_p (const struct bfd *abfd, @@ -1003,6 +1003,12 @@ insert_section_p (const struct bfd *abfd, if ((bfd_section_flags (section) & SEC_THREAD_LOCAL) !=3D 0) /* This is a TLS section. */ return 0; + if (bfd_section_size (section) =3D=3D 0) + { + /* This is an empty section. It has no PCs for find_pc_section (), = so + there is no reason to insert it into the section map. */ + return 0; + } =20 return 1; }