elf: Check bfd_target_elf_flavour on input first

Check bfd_target_elf_flavour on input first in ldelf_after_open before
checking elf_tdata.

	* ldelf.c (ldelf_after_open): Check bfd_target_elf_flavour first.
This commit is contained in:
H.J. Lu 2020-09-15 13:05:04 -07:00
parent 47f0e2ff7f
commit 0403e9ccae
2 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2020-09-15 H.J. Lu <hongjiu.lu@intel.com>
* ldelf.c (ldelf_after_open): Check bfd_target_elf_flavour first.
2020-09-15 Hans-Peter Nilsson <hp@axis.com>
PR ld/26589

View File

@ -1043,7 +1043,8 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
/* Do not allow executable files to be used as inputs to the link. */
for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
{
if (!bfd_input_just_syms (abfd)
if (abfd->xvec->flavour == bfd_target_elf_flavour
&& !bfd_input_just_syms (abfd)
&& elf_tdata (abfd) != NULL
&& elf_tdata (abfd)->elf_header != NULL
/* FIXME: Maybe check for other non-supportable types as well ? */