summaryrefslogtreecommitdiff
path: root/ld/ldelf.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2020-05-28 16:43:01 +0100
committerNick Clifton <nickc@redhat.com>2020-05-28 16:43:01 +0100
commita3fc941881e4224eff3ef20ba1e784026bcc17fa (patch)
tree9eb5ed86c3d6ee5db40ef5ad03e0869acd36e984 /ld/ldelf.c
parent44486dcf19b62708ad49bbb6094e065a223dea99 (diff)
downloadbinutils-gdb-a3fc941881e4224eff3ef20ba1e784026bcc17fa.tar.gz
Stop the linker from accepting executable ELF files as inputs to other links.
PR 26047 * ldelf.c (ldelf_after_open): Fail if attempting to link one executable into another.
Diffstat (limited to 'ld/ldelf.c')
-rw-r--r--ld/ldelf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ld/ldelf.c b/ld/ldelf.c
index efb4b77382e..475fd000e6b 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1065,6 +1065,13 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
{
int type = 0;
+ if (bfd_link_executable (& link_info)
+ && elf_tdata (abfd)->elf_header->e_type == ET_EXEC)
+ {
+ einfo (_("%F%P: cannot use executable file '%pB' as input to a link\n"),
+ abfd);
+ }
+
if (bfd_input_just_syms (abfd))
continue;