This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: PR ld/3107


On Mon, Nov 06, 2006 at 08:40:03AM +1030, Alan Modra wrote:
> Another possibility occurred to me:  You could run
> arm_process_before_allocation both from arm_size_dynamic_sections and
> arm_elf_before_allocation, the latter case only when the former won't
> run (ie. !dynamic_sections_created).  That way you could go back to
> using plt.offset, and wouldn't need to worry that the logic matched.
> I'm a little worried that the current test isn't quite right for
> symbols with non-default visibility.

I convinced myself that it was right, but yes, that would be nicer. 
Like the attached?  (Tested with binutils + glibc tests).

-- 
Daniel Jacobowitz
CodeSourcery

2006-11-07  Daniel Jacobowitz  <dan@codesourcery.com>

	* bfd-in.h (bfd_elf32_arm_process_before_allocation): Update
	prototype.
	(bfd_elf32_arm_set_byteswap_code): New prototype.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (bfd_elf32_arm_process_before_allocation): Don't take
	byteswap_code as an argument.  Revert 2006-11-01 change.
	(bfd_elf32_arm_set_byteswap_code): New.
	(elf32_arm_size_dynamic_sections): Call
	bfd_elf32_arm_process_before_allocation.

2006-11-07  Daniel Jacobowitz  <dan@codesourcery.com>

	* emultempl/armelf.em (arm_elf_before_allocation): Only call
	bfd_elf32_arm_process_before_allocation if no dynamic sections.

2006-11-07  Daniel Jacobowitz  <dan@codesourcery.com

	2006-11-01  Alan Modra  <amodra@bigpond.net.au>

Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.119
diff -u -p -r1.119 bfd-in.h
--- bfd/bfd-in.h	26 Oct 2006 00:01:31 -0000	1.119
+++ bfd/bfd-in.h	7 Nov 2006 14:21:40 -0000
@@ -868,7 +868,7 @@ extern bfd_boolean bfd_elf32_arm_allocat
   (struct bfd_link_info *);
 
 extern bfd_boolean bfd_elf32_arm_process_before_allocation
-  (bfd *, struct bfd_link_info *, int);
+  (bfd *, struct bfd_link_info *);
 
 void bfd_elf32_arm_set_target_relocs
   (struct bfd_link_info *, int, char *, int, int);
@@ -887,6 +887,8 @@ extern bfd_boolean bfd_elf32_arm_add_glu
 extern bfd_boolean bfd_is_arm_special_symbol_name
   (const char * name, int type);
 
+extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.406
diff -u -p -r1.406 bfd-in2.h
--- bfd/bfd-in2.h	30 Oct 2006 23:25:49 -0000	1.406
+++ bfd/bfd-in2.h	7 Nov 2006 14:21:41 -0000
@@ -875,7 +875,7 @@ extern bfd_boolean bfd_elf32_arm_allocat
   (struct bfd_link_info *);
 
 extern bfd_boolean bfd_elf32_arm_process_before_allocation
-  (bfd *, struct bfd_link_info *, int);
+  (bfd *, struct bfd_link_info *);
 
 void bfd_elf32_arm_set_target_relocs
   (struct bfd_link_info *, int, char *, int, int);
@@ -894,6 +894,8 @@ extern bfd_boolean bfd_elf32_arm_add_glu
 extern bfd_boolean bfd_is_arm_special_symbol_name
   (const char * name, int type);
 
+extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.99
diff -u -p -r1.99 elf32-arm.c
--- bfd/elf32-arm.c	3 Nov 2006 00:58:09 -0000	1.99
+++ bfd/elf32-arm.c	7 Nov 2006 14:21:42 -0000
@@ -2828,8 +2828,7 @@ static void check_use_blx(struct elf32_a
 
 bfd_boolean
 bfd_elf32_arm_process_before_allocation (bfd *abfd,
-					 struct bfd_link_info *link_info,
-					 int byteswap_code)
+					 struct bfd_link_info *link_info)
 {
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Rela *internal_relocs = NULL;
@@ -2852,13 +2851,12 @@ bfd_elf32_arm_process_before_allocation 
   BFD_ASSERT (globals != NULL);
   BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
 
-  if (byteswap_code && !bfd_big_endian (abfd))
+  if (globals->byteswap_code && !bfd_big_endian (abfd))
     {
       _bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."),
 			  abfd);
       return FALSE;
     }
-  globals->byteswap_code = byteswap_code;
 
   /* Rummage around all the relocs and map the glue vectors.  */
   sec = abfd->sections;
@@ -2934,19 +2932,9 @@ bfd_elf32_arm_process_before_allocation 
 	  if (h == NULL)
 	    continue;
 
-	  /* If the call will go through a PLT entry then we do not
-	     need glue.  We have to do a fairly complicated check
-	     here, since we don't determine this finally (by setting
-	     plt.offset) until later; this test should be kept in sync
-	     with elf32_arm_adjust_dynamic_symbol.  */
-	  if (globals->splt != NULL
-	      && h->plt.refcount > 0
-	      && (h->type == STT_FUNC
-		  || h->type == STT_ARM_TFUNC
-		  || h->needs_plt)
-	      && !SYMBOL_CALLS_LOCAL (link_info, h)
-	      && !(ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-		   && h->root.type == bfd_link_hash_undefweak))
+	  /* If the call will go through a PLT entry then we do not need
+	     glue.  */
+	  if (globals->splt != NULL && h->plt.offset != (bfd_vma) -1)
 	    continue;
 
 	  switch (r_type)
@@ -7909,6 +7897,16 @@ elf32_arm_readonly_dynrelocs (struct elf
   return TRUE;
 }
 
+void
+bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *info,
+				 int byteswap_code)
+{
+  struct elf32_arm_link_hash_table *globals;
+
+  globals = elf32_arm_hash_table (info);
+  globals->byteswap_code = byteswap_code;
+}
+
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
@@ -8024,6 +8022,13 @@ elf32_arm_size_dynamic_sections (bfd * o
      sym dynamic relocs.  */
   elf_link_hash_traverse (& htab->root, allocate_dynrelocs, info);
 
+  /* Here we rummage through the found bfds to collect glue information.  */
+  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+    if (!bfd_elf32_arm_process_before_allocation (ibfd, info))
+      /* xgettext:c-format */
+      _bfd_error_handler (_("Errors encountered processing file %s"),
+			  ibfd->filename);
+
   /* The check_relocs and adjust_dynamic_symbol entry points have
      determined the sizes of the various dynamic sections.  Allocate
      memory for them.  */
Index: ld/emultempl/armelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armelf.em,v
retrieving revision 1.51
diff -u -p -r1.51 armelf.em
--- ld/emultempl/armelf.em	23 Oct 2006 03:07:49 -0000	1.51
+++ ld/emultempl/armelf.em	7 Nov 2006 14:21:43 -0000
@@ -121,21 +121,22 @@ arm_elf_before_allocation (void)
       if (bfd_for_interwork != NULL)
 	bfd_elf32_arm_get_bfd_for_interworking (bfd_for_interwork, &link_info);
     }
-  /* We should be able to set the size of the interworking stub section.  */
 
-  /* Here we rummage through the found bfds to collect glue information.  */
-  /* FIXME: should this be based on a command line option? krk@cygnus.com  */
-  {
-    LANG_FOR_EACH_INPUT_STATEMENT (is)
-      {
-	if (!bfd_elf32_arm_process_before_allocation (is->the_bfd, & link_info,
-						      byteswap_code))
-	  {
+  bfd_elf32_arm_set_byteswap_code (&link_info, byteswap_code);
+
+  /* We should be able to set the size of the interworking stub section.  We
+     can't do it until later if we have dynamic sections, though.  */
+  if (! elf_hash_table (&link_info)->dynamic_sections_created)
+    {
+      /* Here we rummage through the found bfds to collect glue information.  */
+      LANG_FOR_EACH_INPUT_STATEMENT (is)
+	{
+	  if (!bfd_elf32_arm_process_before_allocation (is->the_bfd,
+							&link_info))
 	    /* xgettext:c-format */
 	    einfo (_("Errors encountered processing file %s"), is->filename);
-	  }
-      }
-  }
+	}
+    }
 
   /* Call the standard elf routine.  */
   gld${EMULATION_NAME}_before_allocation ();


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