This is the mail archive of the binutils@sources.redhat.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: binutils is broken


On Tue, Oct 02, 2001 at 04:43:56PM -0700, H . J . Lu wrote:
>  
> @@ -1132,6 +1103,7 @@ elf_i386_adjust_dynamic_symbol (info, h)
>  		  || h->weakdef->root.type == bfd_link_hash_defweak);
>        h->root.u.def.section = h->weakdef->root.u.def.section;
>        h->root.u.def.value = h->weakdef->root.u.def.value;
> +      return true;
>      }
>  
>    /* This is a reference to a symbol defined by a dynamic object which

The above is the change that actually breaks things (note you had the
diff reversed, so the problem is caused by continuing on and generating
copy relocs for the weakdef).  Doing so defines the symbol in the dynbss
section, and the comment at line 3695 of elflink.h comes into play
because we have a definition for tzname, daylight etc. in the
application.

The real bug is around line 3618 of elflink.h, where flags are copied
to a weakdef.  I think copy_indirect_symbol needs to be called here
instead so that the x86 dyn_relocs field gets copied to the weakdef.
That would make my incorrect fudge in ..adjust_dynamic_symbol not needed.

I'm testing this patch at the moment, and will commit it if all is
well.

	* elflink.h (elf_fix_symbol_flags): Copy flags to weakdef using
	elf_backend_copy_indirect_symbol so that backend has a chance to
	copy other necessary fields.
	* elf.c (_bfd_elf_link_hash_copy_indirect): Bail out after
	copying flags if this is a weakdef.
	* elf32-i386 (elf_i386_adjust_dynamic_symbol): Don't do copy
	reloc processing for weakdefs.

-- 
Alan Modra

Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.110
diff -u -p -r1.110 elflink.h
--- elflink.h	2001/09/29 12:07:00	1.110
+++ elflink.h	2001/10/03 06:26:42
@@ -3615,11 +3615,12 @@ elf_fix_symbol_flags (h, eif)
       if ((weakdef->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
 	h->weakdef = NULL;
       else
-	weakdef->elf_link_hash_flags |=
-	  (h->elf_link_hash_flags
-	   & (ELF_LINK_HASH_REF_REGULAR
-	      | ELF_LINK_HASH_REF_REGULAR_NONWEAK
-	      | ELF_LINK_NON_GOT_REF));
+	{
+	  struct elf_backend_data *bed;
+
+	  bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
+	  (*bed->elf_backend_copy_indirect_symbol) (h->weakdef, h);
+	}
     }
 
   return true;
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.96
diff -u -p -r1.96 elf.c
--- elf.c	2001/09/30 03:03:11	1.96
+++ elf.c	2001/10/03 06:26:47
@@ -986,7 +986,7 @@ _bfd_elf_link_hash_newfunc (entry, table
 }
 
 /* Copy data from an indirect symbol to its direct symbol, hiding the
-   old indirect symbol.  */
+   old indirect symbol.  Also used for copying flags to a weakdef.  */
 
 void
 _bfd_elf_link_hash_copy_indirect (dir, ind)
@@ -1003,6 +1003,9 @@ _bfd_elf_link_hash_copy_indirect (dir, i
 	| ELF_LINK_HASH_REF_REGULAR
 	| ELF_LINK_HASH_REF_REGULAR_NONWEAK
 	| ELF_LINK_NON_GOT_REF));
+
+  if (dir == ind->weakdef)
+    return;
 
   /* Copy over the global and procedure linkage table refcount entries.
      These may have been already set up by a check_relocs routine.  */
Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.52
diff -u -p -r1.52 elf32-i386.c
--- elf32-i386.c	2001/09/29 06:21:59	1.52
+++ elf32-i386.c	2001/10/03 06:26:48
@@ -1109,6 +1109,7 @@ elf_i386_adjust_dynamic_symbol (info, h)
 		  || h->weakdef->root.type == bfd_link_hash_defweak);
       h->root.u.def.section = h->weakdef->root.u.def.section;
       h->root.u.def.value = h->weakdef->root.u.def.value;
+      return true;
     }
 
   /* This is a reference to a symbol defined by a dynamic object which


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