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]
Other format: [Raw text]

PATCH: Don't install bad ia64 trampoline


When a trampoline is out of range, we get

/usr/local/bin/ld: can't relax section: No such file or directory

This patch changes it to

: relocation truncated to fit: PCREL21B foo


H.J.
----
2003-12-12  H.J. Lu  <hongjiu.lu@intel.com>

	* elfxx-ia64.c (elfNN_ia64_relax_section): Don't install
	trampoline if it is known out of range.

--- bfd/elfxx-ia64.c.relax	2003-12-11 16:05:07.000000000 -0800
+++ bfd/elfxx-ia64.c	2003-12-12 11:33:11.000000000 -0800
@@ -886,6 +886,8 @@ elfNN_ia64_relax_section (abfd, sec, lin
 
       if (is_branch)
 	{
+	  bfd_signed_vma offset;
+
 	  reladdr = (sec->output_section->vma
 		     + sec->output_offset
 		     + roff) & (bfd_vma) -4;
@@ -921,6 +923,13 @@ elfNN_ia64_relax_section (abfd, sec, lin
 
 	      /* Resize the current section to make room for the new branch. */
 	      trampoff = (sec->_cooked_size + 15) & (bfd_vma) -16;
+
+	      /* If trampoline is out of range, there is nothing we
+		 can do.  */
+	      offset = trampoff - (roff & (bfd_vma) -4);
+	      if (offset < -0x1000000 || offset > 0x0FFFFF0)
+		continue;
+
 	      amt = trampoff + size;
 	      contents = (bfd_byte *) bfd_realloc (contents, amt);
 	      if (contents == NULL)
@@ -967,14 +976,18 @@ elfNN_ia64_relax_section (abfd, sec, lin
 	    }
 	  else
 	    {
+	      /* If trampoline is out of range, there is nothing we
+		 can do.  */
+	      offset = f->trampoff - (roff & (bfd_vma) -4);
+	      if (offset < -0x1000000 || offset > 0x0FFFFF0)
+		continue;
+
 	      /* Nop out the reloc, since we're finalizing things here.  */
 	      irel->r_info = ELFNN_R_INFO (0, R_IA64_NONE);
 	    }
 
-	  /* Fix up the existing branch to hit the trampoline.  Hope like
-	     hell this doesn't overflow too.  */
-	  if (elfNN_ia64_install_value (abfd, contents + roff,
-					f->trampoff - (roff & (bfd_vma) -4),
+	  /* Fix up the existing branch to hit the trampoline.  */
+	  if (elfNN_ia64_install_value (abfd, contents + roff, offset,
 					r_type) != bfd_reloc_ok)
 	    goto error_return;
 


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