binutils/binutils-objcopy-gnu-build-version-notes.patch

58 lines
2.4 KiB
Diff

--- 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;