PATCH: Fix ldxmov relaxation

H. J. Lu hjl@lucon.org
Fri Apr 18 15:14:00 GMT 2003


On Fri, Apr 18, 2003 at 05:09:21AM -0700, Richard Henderson wrote:
> On Thu, Apr 17, 2003 at 10:02:41PM -0700, H. J. Lu wrote:
> > BTW, there may be a small ldxmov/ltoff22x ld bug. Shouldn't we relax
> > ldxmov/ltoff22x after we finish all brl relaxation?
> 
> Yes.
> 
> > I have a patch for that.
> 
> Eh?  I don't think the current relax_section interface
> supports this.  It's not a small problem.
> 

Here is my patch.

H.J.
-------------- next part --------------
bfd/

2003-04-18  H.J. Lu <hjl@gnu.org>

	* elfxx-ia64.c (elfNN_ia64_relax_section): Relax ldxmov during
	the relax finalize pass.

include/

2003-04-18  H.J. Lu <hjl@gnu.org>

	* bfdlink.h (bfd_link_info): Add relax_finalizing.

ld/

2003-04-18  H.J. Lu <hjl@gnu.org>

	* ldlang.c (lang_process): Add the relax finalize pass.

	* ldmain.c (main): Initialize link_info.relax_finalizing to
	FALSE.

--- binutils/bfd/elfxx-ia64.c.fr	2003-04-18 07:55:59.000000000 -0700
+++ binutils/bfd/elfxx-ia64.c	2003-04-18 07:58:35.000000000 -0700
@@ -756,11 +756,15 @@ elfNN_ia64_relax_section (abfd, sec, lin
 	case R_IA64_PCREL21BI:
 	case R_IA64_PCREL21M:
 	case R_IA64_PCREL21F:
+	  if (link_info->relax_finalizing)
+	    continue;
 	  is_branch = TRUE;
 	  break;
 
 	case R_IA64_LTOFF22X:
 	case R_IA64_LDXMOV:
+	  if (!link_info->relax_finalizing)
+	    continue;
 	  is_branch = FALSE;
 	  break;
 
--- binutils/include/bfdlink.h.fr	2003-01-02 09:57:40.000000000 -0800
+++ binutils/include/bfdlink.h	2003-04-18 07:56:57.000000000 -0700
@@ -288,6 +288,9 @@ struct bfd_link_info
   /* TRUE if global symbols in discarded sections should be stripped.  */
   unsigned int strip_discarded: 1;
 
+  /* TRUE if relaxation is being finalized.  */
+  unsigned int relax_finalizing: 1;
+
   /* Which symbols to strip.  */
   enum bfd_link_strip strip;
 
--- binutils/ld/ldlang.c.fr	2003-04-01 14:29:10.000000000 -0800
+++ binutils/ld/ldlang.c	2003-04-18 07:56:57.000000000 -0700
@@ -4393,6 +4393,14 @@ lang_process ()
 			      abs_output_section,
 			      &statement_list.head, 0, (bfd_vma) 0,
 			      &relax_again, FALSE);
+
+	  /* If the normal relax is done and the relax finalize pass
+	     is not performed yet, we perform another relax pass.  */
+	  if (!relax_again && !link_info.relax_finalizing)
+	    {
+	      link_info.relax_finalizing = TRUE;
+	      relax_again = TRUE;
+	    }
 	}
       while (relax_again);
 
--- binutils/ld/ldmain.c.fr	2003-04-01 14:29:10.000000000 -0800
+++ binutils/ld/ldmain.c	2003-04-18 07:56:57.000000000 -0700
@@ -328,6 +328,7 @@ main (argc, argv)
   link_info.spare_dynamic_tags = 5;
   link_info.flags = (bfd_vma) 0;
   link_info.flags_1 = (bfd_vma) 0;
+  link_info.relax_finalizing = FALSE;
 
   ldfile_add_arch ("");
 


More information about the Binutils mailing list