binutils/binutils-strip-delete-relocs.patch

74 lines
2.4 KiB
Diff

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