[PATCH] Avoid R_IA64_NONE relocations when relaxing

H. J. Lu hjl@lucon.org
Sat Aug 6 05:15:00 GMT 2005


On Sat, Aug 06, 2005 at 02:57:00AM +0200, Andreas Schwab wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
> 
> > The problem is when you reduced the size of .rela.got, gp became too
> > high for relaxed R_IA64_LTOFF22X.
> 
> I have a patch ready that just needs some testing.  Stay tuned.
> 

This patch seems to work for my testcase.


H.J.
---
2005-08-05  H.J. Lu  <hongjiu.lu@intel.com>

	* elfxx-ia64.c (elfNN_ia64_relax_section): Adjust gp after
	resizing .rela.got.

--- bfd/elfxx-ia64.c.xmov	2005-08-05 11:46:46.000000000 -0700
+++ bfd/elfxx-ia64.c	2005-08-05 22:07:46.911667078 -0700
@@ -881,6 +881,7 @@ elfNN_ia64_relax_section (abfd, sec, lin
   bfd_boolean changed_relocs = FALSE;
   bfd_boolean changed_got = FALSE;
   bfd_vma gp = 0;
+  bfd *obfd = NULL;
 
   /* Assume we're not going to change any sizes, and we'll only need
      one pass.  */
@@ -1245,7 +1246,7 @@ elfNN_ia64_relax_section (abfd, sec, lin
 	  /* Fetch the gp.  */
 	  if (gp == 0)
 	    {
-	      bfd *obfd = sec->output_section->owner;
+	      obfd = sec->output_section->owner;
 	      gp = _bfd_get_gp_value (obfd);
 	      if (gp == 0)
 		{
@@ -1341,6 +1342,8 @@ elfNN_ia64_relax_section (abfd, sec, lin
       if (ia64_info->root.dynamic_sections_created
 	  && ia64_info->rel_got_sec != NULL)
 	{
+	  bfd_size_type oldsize = ia64_info->rel_got_sec->size;
+
 	  /* Resize .rela.got.  */
 	  ia64_info->rel_got_sec->size = 0;
 	  if (link_info->shared
@@ -1349,6 +1352,12 @@ elfNN_ia64_relax_section (abfd, sec, lin
 	  data.only_got = TRUE;
 	  elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_dynrel_entries,
 				       &data);
+	  BFD_ASSERT (oldsize >= ia64_info->rel_got_sec->size);
+	  /* We need to adjust gp for R_IA64_LTOFF22X relaxation.  */
+	  if (oldsize > ia64_info->rel_got_sec->size)
+	    _bfd_set_gp_value (obfd,
+			       gp - (oldsize
+				     - ia64_info->rel_got_sec->size));
 	}
     }
 



More information about the Binutils mailing list