[binutils-gdb] Fix a bug in objcopy/strip's ability to merge notes in multiple same-named sections.

Nick Clifton nickc@sourceware.org
Tue Oct 6 14:50:35 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0ec992e6647c00fc234cdf4c11732b6711b024af

commit 0ec992e6647c00fc234cdf4c11732b6711b024af
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Oct 6 15:49:40 2020 +0100

    Fix a bug in objcopy/strip's ability to merge notes in multiple same-named sections.
    
            * objcopy.c (copy_object): Compare input and output sections by
            pointer rather than name.

Diff:
---
 binutils/ChangeLog | 5 +++++
 binutils/objcopy.c | 6 ++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index f5411e3fb3a..b751eeec5e2 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2020-10-06  Nick Clifton  <nickc@redhat.com>
+
+	* objcopy.c (copy_object): Compare input and output sections by
+	pointer rather than name.
+
 2020-10-05  Nick Clifton  <nickc@redhat.com>
 
 	PR 26698
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 1a6fc8a4f59..d777d740cb7 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3322,14 +3322,12 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
 	  /* It is likely that output sections are in the same order
 	     as the input sections, but do not assume that this is
 	     the case.  */
-	  if (strcmp (bfd_section_name (merged->sec),
-		      bfd_section_name (osec)) != 0)
+	  if (merged->sec->output_section != osec)
 	    {
 	      for (merged = merged_note_sections;
 		   merged != NULL;
 		   merged = merged->next)
-		if (strcmp (bfd_section_name (merged->sec),
-			    bfd_section_name (osec)) == 0)
+		if (merged->sec->output_section == osec)
 		  break;
 
 	      if (merged == NULL)


More information about the Binutils-cvs mailing list