Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jun 2019 16:30:35 +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: r349172 - stable/12/contrib/elftoolchain/elfcopy
Message-ID:  <201906181630.x5IGUZAm046335@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Jun 18 16:30:35 2019
New Revision: 349172
URL: https://svnweb.freebsd.org/changeset/base/349172

Log:
  MFC r348654:
  elfcopy: Use elf_getscn() instead of iterating over all sections.
  
  PR:	234949

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

Modified: stable/12/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- stable/12/contrib/elftoolchain/elfcopy/sections.c	Tue Jun 18 16:29:46 2019	(r349171)
+++ stable/12/contrib/elftoolchain/elfcopy/sections.c	Tue Jun 18 16:30:35 2019	(r349172)
@@ -119,21 +119,19 @@ is_remove_reloc_sec(struct elfcopy *ecp, uint32_t sh_i
 		errx(EXIT_FAILURE, "elf_getshstrndx failed: %s",
 		    elf_errmsg(-1));
 
-	is = NULL;
-	while ((is = elf_nextscn(ecp->ein, is)) != NULL) {
-		if (sh_info == elf_ndxscn(is)) {
-			if (gelf_getshdr(is, &ish) == NULL)
-				errx(EXIT_FAILURE, "gelf_getshdr failed: %s",
-				    elf_errmsg(-1));
-			if ((name = elf_strptr(ecp->ein, indx, ish.sh_name)) ==
-			    NULL)
-				errx(EXIT_FAILURE, "elf_strptr failed: %s",
-				    elf_errmsg(-1));
-			if (is_remove_section(ecp, name))
-				return (1);
-			else
-				return (0);
-		}
+	is = elf_getscn(ecp->ein, sh_info);
+	if (is != NULL) {
+		if (gelf_getshdr(is, &ish) == NULL)
+			errx(EXIT_FAILURE, "gelf_getshdr failed: %s",
+			    elf_errmsg(-1));
+		if ((name = elf_strptr(ecp->ein, indx, ish.sh_name)) ==
+		    NULL)
+			errx(EXIT_FAILURE, "elf_strptr failed: %s",
+			    elf_errmsg(-1));
+		if (is_remove_section(ecp, name))
+			return (1);
+		else
+			return (0);
 	}
 	elferr = elf_errno();
 	if (elferr != 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906181630.x5IGUZAm046335>