ldelf_parse_ld_so_conf (info, pattern);
#endif
- if (newp)
- free (newp);
+ free (newp);
}
static bfd_boolean
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)
}
return;
}
-
+
if (!link_info.traditional_format)
{
bfd *elfbfd = NULL;
{
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;
if (elf_section_data (out)->this_hdr.sh_info
!= elf_section_data (in)->this_hdr.sh_info)
return FALSE;
- /* We can't merge with member of output section group nor merge two
- sections with differing SHF_EXCLUDE when doing a relocatable link.
- */
+ /* We can't merge with a member of an output section group or merge
+ two sections with differing SHF_EXCLUDE or other processor and OS
+ specific flags when doing a relocatable link. */
if (bfd_link_relocatable (&link_info)
&& (elf_next_in_group (out) != NULL
|| ((elf_section_flags (out) ^ elf_section_flags (in))
- & SHF_EXCLUDE) != 0))
+ & (SHF_MASKPROC | SHF_MASKOS)) != 0))
return FALSE;
return _bfd_elf_match_sections_by_type (link_info.output_bfd, out,
in->owner, in);