Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Jun 2019 03:03:55 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r348720 - stable/12/contrib/elftoolchain/elfcopy
Message-ID:  <201906060303.x5633t7r057640@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Thu Jun  6 03:03:54 2019
New Revision: 348720
URL: https://svnweb.freebsd.org/changeset/base/348720

Log:
  MFC r348431:
  elfcopy: Optimize for insertions at the end of the section list.
  
  PR:	234949

Modified:
  stable/12/contrib/elftoolchain/elfcopy/elfcopy.h
  stable/12/contrib/elftoolchain/elfcopy/sections.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/elftoolchain/elfcopy/elfcopy.h
==============================================================================
--- stable/12/contrib/elftoolchain/elfcopy/elfcopy.h	Thu Jun  6 03:02:43 2019	(r348719)
+++ stable/12/contrib/elftoolchain/elfcopy/elfcopy.h	Thu Jun  6 03:03:54 2019	(r348720)
@@ -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: stable/12/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- stable/12/contrib/elftoolchain/elfcopy/sections.c	Thu Jun  6 03:02:43 2019	(r348719)
+++ stable/12/contrib/elftoolchain/elfcopy/sections.c	Thu Jun  6 03:03:54 2019	(r348720)
@@ -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?201906060303.x5633t7r057640>