diff options
author | Nick Clifton <nickc@redhat.com> | 2020-05-28 17:43:21 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-05-28 17:43:21 +0100 |
commit | a87e1817a435dab6c6c042f9306497c9f13d4236 (patch) | |
tree | fe25ebf0548d80ba774792afda33bb7366ebd41c /ld/ldelf.c | |
parent | a3fc941881e4224eff3ef20ba1e784026bcc17fa (diff) | |
download | gdb-a87e1817a435dab6c6c042f9306497c9f13d4236.zip gdb-a87e1817a435dab6c6c042f9306497c9f13d4236.tar.gz gdb-a87e1817a435dab6c6c042f9306497c9f13d4236.tar.bz2 |
Have the linker fail if any attempt to link in an executable is made.
PR 26047
* ldelf.c (ldelf_after_open): Fail if attempting to link one
executable into another. Ensure that the test is made for all
forms of linking.
Diffstat (limited to 'ld/ldelf.c')
-rw-r--r-- | ld/ldelf.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1038,6 +1038,17 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd, get_elf_backend_data (link_info.output_bfd)->setup_gnu_properties (&link_info); + /* 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 (elf_tdata (abfd) != NULL + && elf_tdata (abfd)->elf_header != NULL + /* FIXME: Maybe check for other non-supportable types as well ? */ + && 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_link_relocatable (&link_info)) { if (link_info.execstack == !link_info.noexecstack) @@ -1054,7 +1065,7 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd, } return; } - + if (!link_info.traditional_format) { bfd *elfbfd = NULL; |