* [PATCH] elf: Check bfd_target_elf_flavour on input first
@ 2020-09-15 20:07 H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2020-09-15 20:07 UTC (permalink / raw)
To: binutils
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.
---
ld/ChangeLog | 4 ++++
ld/ldelf.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index c65a188736..01587d8621 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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
diff --git a/ld/ldelf.c b/ld/ldelf.c
index 75c6c015ae..c37358f05e 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -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 ? */
--
2.26.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-15 20:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 20:07 [PATCH] elf: Check bfd_target_elf_flavour on input first H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).