Improve objcopy's --merge-notes option.

Relates: #1608390
This commit is contained in:
Nick Clifton 2018-08-06 11:51:44 +01:00
parent 964511b7be
commit 67b290a73f
2 changed files with 71 additions and 1 deletions

View File

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

View File

@ -69,7 +69,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.31.1
Release: 9%{?dist}
Release: 10%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -171,6 +171,10 @@ Patch13: binutils-s390-partial-relro.patch
# Lifetime: Fixed in 2.32
Patch14: binutils-merge-attribute-sections.patch
# Purpose: Improve objcopy's --merge-notes option.
# Lifetime: Fixed in 2.32
Patch15: binutils-note-merge-improvements.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -309,6 +313,7 @@ using libelf instead of BFD.
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -716,6 +721,9 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Mon Aug 06 2018 Nick Clifton <nickc@redhat.com> - 2.31.1-10
- Improve objcopy's --merge-notes option. (#1608390)
* Tue Jul 31 2018 Florian Weimer <fweimer@redhat.com> - 2.31.1-9
- Rebuild with fixed binutils