Stop strip from complaining if the first build note is not a version note.

Resolves: #1736114
This commit is contained in:
Nick Clifton 2019-08-05 17:02:57 +01:00
parent f3c54369c5
commit 9dc3a9d58c
2 changed files with 67 additions and 1 deletions

View File

@ -0,0 +1,57 @@
--- binutils.orig/binutils/objcopy.c 2019-08-05 16:17:56.908552690 +0100
+++ binutils-2.32/binutils/objcopy.c 2019-08-05 16:18:14.985435014 +0100
@@ -1988,7 +1988,6 @@ merge_gnu_build_notes (bfd * abfd, asect
unsigned long previous_open_end = 0;
long relsize;
-
relsize = bfd_get_reloc_upper_bound (abfd, sec);
if (relsize > 0)
{
@@ -2005,7 +2004,8 @@ merge_gnu_build_notes (bfd * abfd, asect
}
/* Make a copy of the notes and convert to our internal format.
- Minimum size of a note is 12 bytes. */
+ Minimum size of a note is 12 bytes. Also locate the version
+ notes and check them. */
pnote = pnotes = (objcopy_internal_note *) xcalloc ((size / 12), sizeof (* pnote));
while (remain >= 12)
{
@@ -2174,12 +2174,10 @@ merge_gnu_build_notes (bfd * abfd, asect
attribute_type_byte = version_1_seen ? 1 : 3;
val_start = attribute_type_byte + 1;
- /* The first note should be the first version note. */
- if (pnotes[0].note.namedata[attribute_type_byte] != GNU_BUILD_ATTRIBUTE_VERSION)
- {
- err = _("bad GNU build attribute notes: first note not version note");
- goto done;
- }
+ /* We used to require that the first note be a version note,
+ but this is no longer enforced. Due to the problems with
+ linking sections with the same name (eg .gnu.build.note.hot)
+ we cannot guarantee that the first note will be a version note. */
/* Now merge the notes. The rules are:
1. Preserve the ordering of the notes.
@@ -2196,8 +2194,9 @@ merge_gnu_build_notes (bfd * abfd, asect
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.
- 6. Notes with the same start and end address can be deleted. */
- for (pnote = pnotes + 1; pnote < pnotes_end; pnote ++)
+ 6. Notes with the same start and end address can be deleted.
+ 7. FIXME: Elminate duplicate version notes - even function specific ones ? */
+ for (pnote = pnotes; pnote < pnotes_end; pnote ++)
{
int note_type;
objcopy_internal_note * back;
@@ -2225,7 +2224,6 @@ merge_gnu_build_notes (bfd * abfd, asect
&& 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;

View File

@ -2,7 +2,7 @@
Summary: A GNU collection of binary utilities Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug} Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.32 Version: 2.32
Release: 20%{?dist} Release: 21%{?dist}
License: GPLv3+ License: GPLv3+
URL: https://sourceware.org/binutils URL: https://sourceware.org/binutils
@ -238,6 +238,11 @@ Patch24: binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch
# Lifetime: Fixed in 2.33 # Lifetime: Fixed in 2.33
Patch25: binutils-rh1736114.patch Patch25: binutils-rh1736114.patch
# Purpose: Change objcopy/strip so that they do not complain if the
# first note in a sequence of build notes is not a version note.
# Lifetime: Fixed in 2.33
Patch26: binutils-objcopy-gnu-build-version-notes.patch
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
Provides: bundled(libiberty) Provides: bundled(libiberty)
@ -389,6 +394,7 @@ Conflicts: gcc-c++ < 4.0.0
%patch23 -p1 %patch23 -p1
%patch24 -p1 %patch24 -p1
%patch25 -p1 %patch25 -p1
%patch26 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59. # We cannot run autotools as there is an exact requirement of autoconf-2.59.
# FIXME - this is no longer true. Maybe try reinstating autotool use ? # FIXME - this is no longer true. Maybe try reinstating autotool use ?
@ -785,6 +791,9 @@ exit 0
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
%changelog %changelog
* Mon Aug 05 2019 Nick Clifton <nickc@redhat.com> - 2.32-21
- Stop strip from complaining if the first build note is not a version note. (#1736114)
* Fri Aug 2 2019 Florian Weimer <fweimer@redhat.com> - 2.32-20 * Fri Aug 2 2019 Florian Weimer <fweimer@redhat.com> - 2.32-20
- Fix ld -Map not to produce corrupt ELF notes (#1736114) - Fix ld -Map not to produce corrupt ELF notes (#1736114)