Date: Thu, 30 May 2019 15:28:49 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348431 - head/contrib/elftoolchain/elfcopy Message-ID: <201905301528.x4UFSnKq030610@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Thu May 30 15:28:48 2019 New Revision: 348431 URL: https://svnweb.freebsd.org/changeset/base/348431 Log: elfcopy: Optimize for insertions at the end of the section list. This is the common case when strip(1) is creating the output file. The change provides a significant speedup when running on ELF files with many sections. PR: 234949 Reviewed by: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20444 Modified: head/contrib/elftoolchain/elfcopy/elfcopy.h head/contrib/elftoolchain/elfcopy/sections.c Modified: head/contrib/elftoolchain/elfcopy/elfcopy.h ============================================================================== --- head/contrib/elftoolchain/elfcopy/elfcopy.h Thu May 30 15:26:39 2019 (r348430) +++ head/contrib/elftoolchain/elfcopy/elfcopy.h Thu May 30 15:28:48 2019 (r348431) @@ -138,6 +138,8 @@ struct section { TAILQ_ENTRY(section) sec_list; /* next section */ }; +TAILQ_HEAD(sectionlist, section); + /* Internal data structure for segments. */ struct segment { uint64_t vaddr; /* virtual addr (VMA) */ Modified: head/contrib/elftoolchain/elfcopy/sections.c ============================================================================== --- head/contrib/elftoolchain/elfcopy/sections.c Thu May 30 15:26:39 2019 (r348430) +++ head/contrib/elftoolchain/elfcopy/sections.c Thu May 30 15:28:48 2019 (r348431) @@ -314,18 +314,18 @@ insert_to_sec_list(struct elfcopy *ecp, struct section { struct section *s; - if (!tail) { + if (tail || TAILQ_EMPTY(&ecp->v_sec) || + TAILQ_LAST(&ecp->v_sec, sectionlist)->off <= sec->off) { + TAILQ_INSERT_TAIL(&ecp->v_sec, sec, sec_list); + } else { TAILQ_FOREACH(s, &ecp->v_sec, sec_list) { if (sec->off < s->off) { TAILQ_INSERT_BEFORE(s, sec, sec_list); - goto inc_nos; + break; } } } - TAILQ_INSERT_TAIL(&ecp->v_sec, sec, sec_list); - -inc_nos: if (sec->pseudo == 0) ecp->nos++; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905301528.x4UFSnKq030610>