Linker script PROVIDE statements

Alan Modra amodra@bigpond.net.au
Mon Feb 23 06:26:00 GMT 2004


On Fri, Feb 20, 2004 at 05:06:28PM +0000, Nathan Sidwell wrote:
> Simply creating an undefined symbol in fold_name is insufficient.

I expected so, which is why I said "Try".  :)  The patch looks mostly
good, except for this hunk which just seems to complicate the logic
without actually changing much.

> --- 711,759 ----
>   					create, FALSE, FALSE);
>   	      if (h == NULL)
>   		{
> ! 		  if (create)
>   		    einfo (_("%P%F:%s: hash creation failed\n"),
> ! 		       tree->assign.dst);
> ! 		  update = FALSE;
>   		}
> ! 	      else if (h->type == bfd_link_hash_new
> ! 		       || h->type == bfd_link_hash_undefined
> ! 		       || h->type == bfd_link_hash_common)
> ! 		update = TRUE;
> ! 	      else if (h->type != bfd_link_hash_defined
> ! 		       && h->type != bfd_link_hash_defweak)
> ! 		update = FALSE;
> ! 	      else if (!bfd_is_abs_section (h->u.def.section)
> ! 		       && (bfd_is_abs_section
> ! 			   (h->u.def.section->output_section)))
> ! 		/* If it's already defined to a symbol with an
> ! 		   absolute output section, it's not really a
> ! 		   redefinition, because that is how we indicate
> ! 		   sections that will be discarded.  */
> ! 		update = TRUE;
> ! 	      else if (tree->type.node_class == etree_assign)
>   		{
> ! #if 0
> ! 		  /* This test breaks shared object linking, as those
> ! 		     have their own etext, __bss_start etc, which
> ! 		     conflicts.  The dynamic linking scripts should be
> ! 		     fixed.  */
> ! 		  if (lang_statement_iteration == 1
> ! 		      && (result.value != h->u.def.value
> ! 			  || result.section->bfd_section != h->u.def.section))
> ! 		    einfo (
> ! 	_("%F%P:%s: symbol defined in linker script and object file\n"),
> ! 			   tree->assign.dst);
> ! #endif
> ! 		  update = TRUE;
>   		}
> + 	      else if (tree->type.node_class == etree_provided)
> + 		update = TRUE;
>   	      else
> + 		update = FALSE;
> + 	      
> + 	      if (update)
>   		{
>   		  lang_update_definedness (tree->assign.dst, h);
>   		  h->type = bfd_link_hash_defined;
>   		  h->u.def.value = result.value;

I think you could just use the following, which also fixes a bug in
that we should follow indirect symbols here.

Index: ld/ldexp.c
===================================================================
RCS file: /cvs/src/src/ld/ldexp.c,v
retrieving revision 1.27
diff -u -p -r1.27 ldexp.c
--- ld/ldexp.c	3 Jan 2004 12:39:07 -0000	1.27
+++ ld/ldexp.c	23 Feb 2004 06:20:13 -0000
@@ -729,14 +729,15 @@ exp_fold_tree (etree_type *tree,
 	      else
 		create = FALSE;
 	      h = bfd_link_hash_lookup (link_info.hash, tree->assign.dst,
-					create, FALSE, FALSE);
+					create, FALSE, TRUE);
 	      if (h == NULL)
 		{
-		  if (tree->type.node_class == etree_assign)
+		  if (create)
 		    einfo (_("%P%F:%s: hash creation failed\n"),
 			   tree->assign.dst);
 		}
 	      else if (tree->type.node_class == etree_provide
+		       && h->type != bfd_link_hash_new
 		       && h->type != bfd_link_hash_undefined
 		       && h->type != bfd_link_hash_common)
 		{

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list