This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Can I link a.out .o with ELF?


On Tue, Jun 06, 2000 at 12:28:01AM +1000, Alan Modra wrote:
> On Sun, 4 Jun 2000, H . J . Lu wrote:
> 
> > On Sun, Jun 04, 2000 at 09:31:30PM -0700, H . J . Lu wrote:
> > > 
> > > It seems that ELF_LINK_NON_ELF doesn't work too well with symbol
> > > versioning. As the result, when a verioned symbol is referenced
> > > in an a.out .o file, the ELF_LINK_NON_ELF bit on the default symbol
> > > is not set. I am not sure what else is not working right.
> > > 
> > 
> > I have a patch to stop ld from dumping core. But it still doesn't
> > work right. On Linux/ia32/glibc 2.1 or glibc 2.2:
> 
> This patch seems to cure your testcase.  Warning: I have no idea whether
> it's the ideal solution, or even correct.  Ian may be able to give a
> better solution.
> 
> Regards, Alan Modra.
> --
> Linuxcare.  Support for the Revolution.
> 
> 
> 	* elflink.h (elf_link_add_object_symbols): Set hash flags for
> 	NON_ELF short name references of versioned symbols.
> 	(elf_fix_symbol_flags): Follow the link for indirect symbols.
> 
> 

How about this patch? It works for my testcases except for building
ELF DSO.


H.J.
---
2000-06-05  Alan Modra  <alan@linuxcare.com.au>

	* elflink.h (elf_fix_symbol_flags): Follow the link for
	indirect symbols.

2000-06-05  H.J. Lu  <hjl@gnu.org>

	* elflink.h (elf_link_output_extsym): Don't output the indirect
	symbol even if the ELF_LINK_NON_ELF bit is set.

Index: elflink.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.h,v
retrieving revision 1.30
diff -u -p -r1.30 elflink.h
--- elflink.h	2000/05/30 21:05:11	1.30
+++ elflink.h	2000/06/05 15:53:44
@@ -3283,11 +3283,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)
@@ -5030,10 +5034,8 @@ elf_link_output_extsym (h, data)
          symbol foo@@GNU_1.2 is the default, which should be used when
          foo is used with no version, then we add an indirect symbol
          foo which points to foo@@GNU_1.2.  We ignore these symbols,
-         since the indirected symbol is already in the hash table.  If
-         the indirect symbol is non-ELF, fall through and output it.  */
-      if ((h->elf_link_hash_flags & ELF_LINK_NON_ELF) == 0)
-	return true;
+         since the indirected symbol is already in the hash table.  */
+      return true;
 
       /* Fall through.  */
     case bfd_link_hash_warning:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]