This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Patch: Check input format against output
On Sat, Mar 24, 2001 at 12:14:30PM -0800, Ian Lance Taylor wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
>
> > > The native linker on SCO Unixware 7, different from GNU ld on GNU/Linux,
> > > can detect this and issues an error message:
> > > UX:ld: ERROR: libtask.a(tri_des.o): fatal error: libtask.a(tri_des.o): wrong machine type
> > >
> > > Could GNU ld (or libbfd) do the same?
> >
> > Here is a patch. Any comments?
> >
> > 2001-03-23 H.J. Lu <hjl@gnu.org>
> >
> > * elflink.h (elf_link_input_bfd): Return false if the input
> > format doesn't matches output.
>
> I don't think this patch is correct as it stands.
>
> This kind of check would normally be handled in the
> merge_private_bfd_data routine of the output BFD.
>
merge_private_bfd_data is defined as bfd_true for many ELF targets.
If we put this check into merge_private_bfd_data, we may have to touch
many ELF files.
> See also lang_check in ld/ldlang.c. Why is that check not being
> triggered by this test case?
>
lang_check calls bfd_arch_get_compatible:
const bfd_arch_info_type *
bfd_arch_get_compatible (abfd, bbfd)
const bfd *abfd;
const bfd *bbfd;
{
/* If either architecture is unknown, then all we can do is assume
the user knows what he's doing. */
if (abfd->arch_info->arch == bfd_arch_unknown)
return bbfd->arch_info;
if (bbfd->arch_info->arch == bfd_arch_unknown)
return abfd->arch_info;
/* Otherwise architecture-specific code has to decide. */
return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info);
}
If the arch for abfd is not configured in BFD, abfd->arch_info->arch
will be bfd_arch_unknown.
H.J.