[PATCH] Remove useless loop

Tristan Gingold gingold@adacore.com
Thu Dec 3 13:48:00 GMT 2015


Hello,

I don’t understand the purpose of a loop in rewrite_elf_program_header:

      for (section = ibfd->sections;
 	   section != NULL;
 	   section = section->next)
	if (section == first_section)
	  break;

Why not simply assign section to first_section ?
Looks too obvious.

No regression for target i386 gnu/linux.
Ok to push ?

Tristan.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b87f914..5365e64 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2015-12-03  Tristan Gingold  <gingold@adacore.com>
+
+	* elf.c (rewrite_elf_program_header): Remove useless loop.
+
 2015-11-20  Stefan Teleman  <stefan.teleman@oracle.com>
 
 	PR ld/19260
diff --git a/bfd/elf.c b/bfd/elf.c
index 7f38fa0..9a2cff5 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6380,13 +6380,9 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
       first_matching_lma = TRUE;
       first_suggested_lma = TRUE;
 
-      for (section = ibfd->sections;
+      for (section = first_section, j = 0;
 	   section != NULL;
 	   section = section->next)
-	if (section == first_section)
-	  break;
-
-      for (j = 0; section != NULL; section = section->next)
 	{
 	  if (INCLUDE_SECTION_IN_SEGMENT (section, segment, bed))
 	    {



More information about the Binutils mailing list