From: Nick Clifton Date: Thu, 28 May 2020 15:43:01 +0000 (+0100) Subject: Stop the linker from accepting executable ELF files as inputs to other links. X-Git-Url: http://git.efficios.com/?p=deliverable%2Fbinutils-gdb.git;a=commitdiff_plain;h=a3fc941881e4224eff3ef20ba1e784026bcc17fa 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. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index c4d9f89cd1..096b9a5398 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2020-05-28 Nick Clifton + + PR 26047 + * ldelf.c (ldelf_after_open): Fail if attempting to link one + executable into another. + 2020-05-28 H.J. Lu * NEWS: Mention --enable-textrel-check=yes is default for diff --git a/ld/ldelf.c b/ld/ldelf.c index efb4b77382..475fd000e6 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;