public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@zembu.com>
To: alan@linuxcare.com.au
Cc: hjl@lucon.org, binutils@sourceware.cygnus.com
Subject: Re: Can I link a.out .o with ELF?
Date: Mon, 05 Jun 2000 09:49:00 -0000	[thread overview]
Message-ID: <20000605153906.8832.qmail@daffy.airs.com> (raw)
In-Reply-To: <Pine.LNX.4.21.0006060014590.11681-100000@front.linuxcare.com.au>

   Date: Tue, 6 Jun 2000 00:28:01 +1000 (EST)
   From: Alan Modra <alan@linuxcare.com.au>

   Index: elflink.h
   ===================================================================
   RCS file: /cvs/src/src/bfd/elflink.h,v
   retrieving revision 1.58
   diff -u -p -r1.58 elflink.h
   --- elflink.h	2000/05/30 20:51:36	1.58
   +++ elflink.h	2000/06/05 14:23:33
   @@ -1741,6 +1741,20 @@ elf_link_add_object_symbols (abfd, info)
			 ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
			 (*bed->elf_backend_copy_indirect_symbol) (ht, hi);

   +		      if ((hi->elf_link_hash_flags & ELF_LINK_NON_ELF) != 0)
   +			{
   +			  if (dynamic)
   +			    hi->elf_link_hash_flags |=
   +			      ELF_LINK_HASH_DEF_DYNAMIC;
   +			  else
   +			    hi->elf_link_hash_flags |=
   +			      ELF_LINK_HASH_DEF_REGULAR;
   +
   +			  ht->elf_link_hash_flags |=
   +			    (ELF_LINK_HASH_REF_REGULAR
   +			     | ELF_LINK_HASH_REF_REGULAR_NONWEAK);
   +			}
   +
			 /* See if the new flags lead us to realize that
			    the symbol must be dynamic.  */
			 if (! dynsym)

I don't understand why you would ever want to set DEF_DYNAMIC here.
You should only get ELF_LINK_NON_ELF when the symbol appears in a
non-ELF file.  The ELF linker does not support linking against a
non-ELF dynamic library.

It should only be necessary to set DEF_REGULAR if the symbol is in
fact defined in a non-ELF file.  Similarly, it should only be
necessary to set REF_REGULAR and REF_REGULAR_NONWEAK if the symbol is
referenced in a non-ELF file.  The code above may well be correct on
this, although I don't really understand why we need to set them here
as opposed to various other places.

   @@ -3283,11 +3297,15 @@ elf_fix_symbol_flags (h, eif)
	 struct elf_link_hash_entry *h;
	 struct elf_info_failed *eif;
    {
   +  struct elf_link_hash_entry *ho = h;
   +  while (h->root.type == bfd_link_hash_indirect)
   +    h = (struct elf_link_hash_entry *) h->root.u.i.link;
   +
      /* If this symbol was mentioned in a non-ELF file, try to set
	 DEF_REGULAR and REF_REGULAR correctly.  This is the only way to
	 permit a non-ELF file to correctly refer to a symbol defined in
	 an ELF dynamic object.  */
   -  if ((h->elf_link_hash_flags & ELF_LINK_NON_ELF) != 0)
   +  if ((ho->elf_link_hash_flags & ELF_LINK_NON_ELF) != 0)
	{
	  if (h->root.type != bfd_link_hash_defined
	     && h->root.type != bfd_link_hash_defweak)

I don't think it is right to change h here.  elf_fix_symbol_flags
should get called for every h.

I don't quite see why you are doing this.  I assume it has something
to do with the call from elf_link_assign_sym_version.  But I don't see
why it works.

What happens if you just patch elf_link_assign_sym_version to work on
NON_ELF symbols as well as DEF_REGULAR symbols?

Ian

  parent reply	other threads:[~2000-06-05  9:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-04 18:07 H . J . Lu
2000-06-04 18:16 ` H . J . Lu
2000-06-04 18:30 ` Alan Modra
2000-06-04 18:38   ` H . J . Lu
2000-06-04 21:31     ` H . J . Lu
2000-06-04 22:17       ` H . J . Lu
2000-06-05  7:28         ` Alan Modra
2000-06-05  7:57           ` H . J . Lu
2000-06-05  8:58           ` H . J . Lu
2000-06-05  9:49           ` Ian Lance Taylor [this message]
2000-06-05 10:15             ` H . J . Lu
2000-06-05 10:16               ` Ian Lance Taylor
2000-06-05 10:23                 ` H . J . Lu
2000-06-05  7:46   ` H . J . Lu
2000-06-05 10:54 Mark Kettenis
2000-06-05 11:15 ` H . J . Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000605153906.8832.qmail@daffy.airs.com \
    --to=ian@zembu.com \
    --cc=alan@linuxcare.com.au \
    --cc=binutils@sourceware.cygnus.com \
    --cc=hjl@lucon.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).