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

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