Blame SOURCES/binutils-note-merge-improvements.patch

381f6c
--- binutils.orig/binutils/objcopy.c	2018-08-06 09:11:02.053503486 +0100
381f6c
+++ binutils-2.30/binutils/objcopy.c	2018-08-06 09:11:23.296329566 +0100
381f6c
@@ -2174,7 +2174,7 @@ merge_gnu_build_notes (bfd * abfd, asect
381f6c
      3. Eliminate any NT_GNU_BUILD_ATTRIBUTE_OPEN notes that have the same
381f6c
         full name field as the immediately preceeding note with the same type
381f6c
 	of name and whose address ranges coincide.
381f6c
-	IE - it there are gaps in the coverage of the notes, then these gaps
381f6c
+	IE - if there are gaps in the coverage of the notes, then these gaps
381f6c
 	must be preserved.
381f6c
      4. Combine the numeric value of any NT_GNU_BUILD_ATTRIBUTE_OPEN notes
381f6c
         of type GNU_BUILD_ATTRIBUTE_STACK_SIZE.
381f6c
@@ -2182,16 +2182,48 @@ merge_gnu_build_notes (bfd * abfd, asect
381f6c
         its description field is empty then the nearest preceeding OPEN note
381f6c
 	with a non-empty description field must also be preserved *OR* the
381f6c
 	description field of the note must be changed to contain the starting
381f6c
-	address to which it refers.  */
381f6c
+	address to which it refers.
381f6c
+     6. Notes with the same start and end address can be deleted.  */
381f6c
   for (pnote = pnotes + 1; pnote < pnotes_end; pnote ++)
381f6c
     {
381f6c
       int                      note_type;
381f6c
       objcopy_internal_note *  back;
381f6c
       objcopy_internal_note *  prev_open_with_range = NULL;
381f6c
 
381f6c
+      /* Rule 6 - delete 0-range notes.  */
381f6c
+      if (pnote->start == pnote->end)
381f6c
+	{
381f6c
+	  duplicate_found = TRUE;
381f6c
+	  pnote->note.type = 0;
381f6c
+	  continue;
381f6c
+	}
381f6c
+
381f6c
       /* Rule 2 - preserve function notes.  */
381f6c
       if (! is_open_note (pnote))
381f6c
-	continue;
381f6c
+	{
381f6c
+	  int iter;
381f6c
+
381f6c
+	  /* Check to see if there is an identical previous function note.
381f6c
+	     This can happen with overlays for example.  */
381f6c
+	  for (iter = 0, back = pnote -1; back >= pnotes; back --)
381f6c
+	    {
381f6c
+	      if (back->start == pnote->start
381f6c
+		  && back->end == pnote->end
381f6c
+		  && back->note.namesz == pnote->note.namesz
381f6c
+		  && memcmp (back->note.namedata, pnote->note.namedata, pnote->note.namesz) == 0)
381f6c
+		{
381f6c
+ fprintf (stderr, "DUP FUNXC\n");
381f6c
+		  duplicate_found = TRUE;
381f6c
+		  pnote->note.type = 0;
381f6c
+		  break;
381f6c
+		}
381f6c
+
381f6c
+	      /* Don't scan too far back however.  */
381f6c
+	      if (iter ++ > 16)
381f6c
+		break;
381f6c
+	    }
381f6c
+	  continue;
381f6c
+	}
381f6c
 
381f6c
       note_type = pnote->note.namedata[attribute_type_byte];
381f6c