Stop strip from crashing when deleteing relocs in a file with annobin notes.
Resolves: #1520805
This commit is contained in:
parent
3790a4edfd
commit
9d3e1de5e1
73
binutils-strip-delete-relocs.patch
Normal file
73
binutils-strip-delete-relocs.patch
Normal file
@ -0,0 +1,73 @@
|
||||
diff -rup binutils.orig/bfd/elf64-sparc.c binutils-2.29.1/bfd/elf64-sparc.c
|
||||
--- binutils.orig/bfd/elf64-sparc.c 2017-12-07 17:23:06.764174312 +0000
|
||||
+++ binutils-2.29.1/bfd/elf64-sparc.c 2017-12-07 17:23:20.540009839 +0000
|
||||
@@ -287,6 +287,7 @@ elf64_sparc_set_reloc (bfd *abfd ATTRIBU
|
||||
unsigned int count)
|
||||
{
|
||||
asect->orelocation = location;
|
||||
+ asect->reloc_count = count / 2;
|
||||
canon_reloc_count (asect) = count;
|
||||
}
|
||||
|
||||
Only in binutils-2.29.1/bfd: elf64-sparc.c.orig
|
||||
diff -rup binutils.orig/bfd/elfcode.h binutils-2.29.1/bfd/elfcode.h
|
||||
--- binutils.orig/bfd/elfcode.h 2017-12-07 17:23:06.722174814 +0000
|
||||
+++ binutils-2.29.1/bfd/elfcode.h 2017-12-07 17:23:20.541009827 +0000
|
||||
@@ -958,6 +958,12 @@ elf_write_relocs (bfd *abfd, asection *s
|
||||
return;
|
||||
}
|
||||
|
||||
+ if (ptr->howto == NULL)
|
||||
+ {
|
||||
+ *failedp = TRUE;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
src_rela.r_offset = ptr->address + addr_offset;
|
||||
src_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
|
||||
src_rela.r_addend = ptr->addend;
|
||||
diff -rup binutils.orig/binutils/objcopy.c binutils-2.29.1/binutils/objcopy.c
|
||||
--- binutils.orig/binutils/objcopy.c 2017-12-07 17:23:06.769174253 +0000
|
||||
+++ binutils-2.29.1/binutils/objcopy.c 2017-12-07 17:23:20.542009815 +0000
|
||||
@@ -3785,14 +3785,24 @@ copy_relocations_in_section (bfd *ibfd,
|
||||
}
|
||||
else
|
||||
{
|
||||
- relpp = (arelent **) xmalloc (relsize);
|
||||
- relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
|
||||
- if (relcount < 0)
|
||||
+ if (isection->orelocation != NULL)
|
||||
{
|
||||
- status = 1;
|
||||
- bfd_nonfatal_message (NULL, ibfd, isection,
|
||||
- _("relocation count is negative"));
|
||||
- return;
|
||||
+ /* Some other function has already set up the output relocs
|
||||
+ for us, so scan those instead of the default relocs. */
|
||||
+ relcount = isection->reloc_count;
|
||||
+ relpp = isection->orelocation;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ relpp = (arelent **) xmalloc (relsize);
|
||||
+ relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
|
||||
+ if (relcount < 0)
|
||||
+ {
|
||||
+ status = 1;
|
||||
+ bfd_nonfatal_message (NULL, ibfd, isection,
|
||||
+ _("relocation count is negative"));
|
||||
+ return;
|
||||
+ }
|
||||
}
|
||||
|
||||
if (strip_symbols == STRIP_ALL)
|
||||
@@ -3815,7 +3825,8 @@ copy_relocations_in_section (bfd *ibfd,
|
||||
temp_relpp [temp_relcount++] = relpp [i];
|
||||
}
|
||||
relcount = temp_relcount;
|
||||
- free (relpp);
|
||||
+ if (isection->orelocation == NULL)
|
||||
+ free (relpp);
|
||||
relpp = temp_relpp;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@
|
||||
Summary: A GNU collection of binary utilities
|
||||
Name: %{?cross}binutils%{?_with_debug:-debug}
|
||||
Version: 2.29
|
||||
Release: 8%{?dist}
|
||||
Release: 9%{?dist}
|
||||
License: GPLv3+
|
||||
Group: Development/Tools
|
||||
URL: http://sources.redhat.com/binutils
|
||||
@ -130,6 +130,11 @@ Patch10: binutils-2.29-non-elf-orphan-skip.patch
|
||||
# Lifetime: Fixed in 2.29.1.
|
||||
Patch11: binutils-2.28-ignore-gold-duplicates.patch
|
||||
|
||||
# Purpose: Fixes a bug in strip/objcopy which could cause it to crash when
|
||||
# deleting relocs in a file which also contains mergeable notes.
|
||||
# Lifetime: Fixed in 2.30.
|
||||
Patch12: binutils-strip-delete-relocs.patch
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
Provides: bundled(libiberty)
|
||||
@ -264,6 +269,7 @@ using libelf instead of BFD.
|
||||
%patch09 -p1
|
||||
%patch10 -p1
|
||||
%patch11 -p1
|
||||
%patch12 -p1
|
||||
|
||||
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
|
||||
|
||||
@ -661,6 +667,9 @@ exit 0
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
%changelog
|
||||
* Fri Dec 08 2017 Nick Clifton <nickc@redhat.com> 2.29-9
|
||||
- Stop strip from crashing when deleteing relocs in a file with annobin notes. (#1520805)
|
||||
|
||||
* Wed Dec 06 2017 Nick Clifton <nickc@redhat.com> 2.29-8
|
||||
- Have readelf return an exit failure status when attempting to process an empty file. (#1522732)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user