This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: RFC: Add output_bfd to bfd_link_info
On Fri, Apr 23, 2004 at 09:27:20PM +0930, Alan Modra wrote:
> On Thu, Apr 22, 2004 at 07:47:14PM -0700, H. J. Lu wrote:
> > There are a few places where bfd_link_info is modifed to include
> > output_bfd. If output_bfd is in bfd_link_info, it is not needed.
>
> You're talking about the last param to elf_link_hash_traverse, aren't
> you? The places I see that pass output_bfd there also need to pass
> other extra data, so adding output_bfd to bfd_link_info won't remove the
> need for a struct containing a bfd_link_info pointer and other data.
That is true. I always find it clearer for bfd_link_info to have both
input and output bfds.
>
> I'm not against the patch, but where do you plan to use
> info->output_bfd?
In _bfd_generic_link_add_one_symbol. In _bfd_elf_fix_symbol_flags,
there are
/* Unfortunately, ELF_LINK_NON_ELF is only correct if the symbol
was first seen in a non-ELF file. Fortunately, if the symbol
was first seen in an ELF file, we're probably OK unless the
symbol was defined in a non-ELF file. Catch that case here.
FIXME: We're still in trouble if the symbol was first seen in
a dynamic object, and then later in a non-ELF regular object.
We can fix it by checking if the input file has the same format as
the output by
if (abfd->xvec->flavour != info->output_bfd->xvec->flavour)
bfd_mark_foreign_symbol (info->output_bfd, h);
For ELF, it will be
void
_bfd_elf_mark_foreign_symbol (bfd *abfd ATTRIBUTE_UNUSED,
struct bfd_link_hash_entry *hash)
{
struct elf_link_hash_entry *h = (struct elf_link_hash_entry *) hash;
h->elf_link_hash_flags |= ELF_LINK_NON_ELF;
}
For others, it will be a no op.
H.J.