X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=ld%2Fldelf.c;h=8f2167e8895ef3bdd5029ff2f5c247ad868c3617;hb=c5316fc6e634858a3821e612e613342da562e0b3;hp=fa4bf9f7278393a6a30a8e2e17b6ae7fdb606755;hpb=1db6f990303ab6c45909f8e133641ef6c24a04d2;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/ldelf.c b/ld/ldelf.c index fa4bf9f727..8f2167e889 100644 --- a/ld/ldelf.c +++ b/ld/ldelf.c @@ -783,8 +783,7 @@ ldelf_parse_ld_so_conf_include (struct ldelf_ld_so_conf *info, ldelf_parse_ld_so_conf (info, pattern); #endif - if (newp) - free (newp); + free (newp); } static bfd_boolean @@ -1039,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) @@ -1055,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; @@ -1066,6 +1076,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;