You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.0 KiB
54 lines
2.0 KiB
3 years ago
|
diff -rup binutils.orig/bfd/elf.c binutils-2.35/bfd/elf.c
|
||
|
--- binutils.orig/bfd/elf.c 2021-04-19 10:49:21.757290990 +0100
|
||
|
+++ binutils-2.35/bfd/elf.c 2021-04-19 10:50:28.309839285 +0100
|
||
|
@@ -12534,7 +12534,9 @@ _bfd_elf_slurp_secondary_reloc_section (
|
||
|
Elf_Internal_Shdr * hdr = & elf_section_data (relsec)->this_hdr;
|
||
|
|
||
|
if (hdr->sh_type == SHT_SECONDARY_RELOC
|
||
|
- && hdr->sh_info == (unsigned) elf_section_data (sec)->this_idx)
|
||
|
+ && hdr->sh_info == (unsigned) elf_section_data (sec)->this_idx
|
||
|
+ && (hdr->sh_entsize == ebd->s->sizeof_rel
|
||
|
+ || hdr->sh_entsize == ebd->s->sizeof_rela))
|
||
|
{
|
||
|
bfd_byte * native_relocs;
|
||
|
bfd_byte * native_reloc;
|
||
|
diff -rup binutils.orig/bfd/elfcode.h binutils-2.35/bfd/elfcode.h
|
||
|
--- binutils.orig/bfd/elfcode.h 2021-04-19 10:49:21.767290922 +0100
|
||
|
+++ binutils-2.35/bfd/elfcode.h 2021-04-19 10:52:22.196066303 +0100
|
||
|
@@ -568,7 +568,7 @@ elf_object_p (bfd *abfd)
|
||
|
|
||
|
/* If this is a relocatable file and there is no section header
|
||
|
table, then we're hosed. */
|
||
|
- if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_type == ET_REL)
|
||
|
+ if (i_ehdrp->e_shoff < sizeof (x_ehdr) && i_ehdrp->e_type == ET_REL)
|
||
|
goto got_wrong_format_error;
|
||
|
|
||
|
/* As a simple sanity check, verify that what BFD thinks is the
|
||
|
@@ -578,7 +578,7 @@ elf_object_p (bfd *abfd)
|
||
|
goto got_wrong_format_error;
|
||
|
|
||
|
/* Further sanity check. */
|
||
|
- if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_shnum != 0)
|
||
|
+ if (i_ehdrp->e_shoff < sizeof (x_ehdr) && i_ehdrp->e_shnum != 0)
|
||
|
goto got_wrong_format_error;
|
||
|
|
||
|
ebd = get_elf_backend_data (abfd);
|
||
|
@@ -615,7 +615,7 @@ elf_object_p (bfd *abfd)
|
||
|
&& ebd->elf_osabi != ELFOSABI_NONE)
|
||
|
goto got_wrong_format_error;
|
||
|
|
||
|
- if (i_ehdrp->e_shoff != 0)
|
||
|
+ if (i_ehdrp->e_shoff >= sizeof (x_ehdr))
|
||
|
{
|
||
|
file_ptr where = (file_ptr) i_ehdrp->e_shoff;
|
||
|
|
||
|
@@ -807,7 +807,7 @@ elf_object_p (bfd *abfd)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- if (i_ehdrp->e_shstrndx != 0 && i_ehdrp->e_shoff != 0)
|
||
|
+ if (i_ehdrp->e_shstrndx != 0 && i_ehdrp->e_shoff >= sizeof (x_ehdr))
|
||
|
{
|
||
|
unsigned int num_sec;
|
||
|
|