PR28346, segfault attempting to disassemble raw binary

Message ID YU2NdUuGKZUV8G+e@squeak.grove.modra.org
State New
Headers show
Series
  • PR28346, segfault attempting to disassemble raw binary
Related show

Commit Message

Alan Modra via Binutils Sept. 24, 2021, 8:33 a.m.
Don't attempt to access elf_section_data for non-ELF sections.

OK?

	PR 28346
	* elf32-xtensa.c (xtensa_read_table_entries): Return zero entries
	for non-ELF.


-- 
Alan Modra
Australia Development Lab, IBM

Comments

Alan Modra via Binutils Sept. 24, 2021, 10:08 a.m. | #1
On Fri, Sep 24, 2021 at 1:34 AM Alan Modra <amodra@gmail.com> wrote:
>

> Don't attempt to access elf_section_data for non-ELF sections.

>

> OK?


Looks good to me. Thank you.

>         PR 28346

>         * elf32-xtensa.c (xtensa_read_table_entries): Return zero entries

>         for non-ELF.

>

> diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c

> index 59f3dd55251..e5bfbb2f509 100644

> --- a/bfd/elf32-xtensa.c

> +++ b/bfd/elf32-xtensa.c

> @@ -885,7 +885,8 @@ xtensa_read_table_entries (bfd *abfd,

>    flagword predef_flags;

>    bfd_size_type table_entry_size, section_limit;

>

> -  if (!section

> +  if (bfd_get_flavour (abfd) != bfd_target_elf_flavour

> +      || !section

>        || !(section->flags & SEC_ALLOC)

>        || (section->flags & SEC_DEBUGGING))

>      {

>


-- 
Thanks.
-- Max

Patch

diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 59f3dd55251..e5bfbb2f509 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -885,7 +885,8 @@  xtensa_read_table_entries (bfd *abfd,
   flagword predef_flags;
   bfd_size_type table_entry_size, section_limit;
 
-  if (!section
+  if (bfd_get_flavour (abfd) != bfd_target_elf_flavour
+      || !section
       || !(section->flags & SEC_ALLOC)
       || (section->flags & SEC_DEBUGGING))
     {