PATCH: Report section and and file for ia64 relocation overflow

H. J. Lu hjl@lucon.org
Wed Oct 20 00:53:00 GMT 2004


Certain ia64 relocations have to be against small data sections.
Otherwise, linker will complain

foo (.text+0x46b2): In function `x()': relocation truncated to fit: GPREL22 y 

It isn't clear why it fails. With this patch, I got

foo.o (.text+0x46b2): In function `x()': relocation truncated to fit: GPREL22 `y' defined in section .bss in bar.o

Now it is clear that it is a compiler bug.


H.J.
---
2004-10-19  H.J. Lu  <hongjiu.lu@intel.com>

	* elfxx-ia64.c (elfNN_ia64_relocate_section): Report section
	and file for relocation overflow.

--- bfd/elfxx-ia64.c.small	2004-10-19 10:44:08.308127265 -0700
+++ bfd/elfxx-ia64.c	2004-10-19 17:45:15.136867879 -0700
@@ -4532,10 +4532,38 @@ elfNN_ia64_relocate_section (output_bfd,
 	case bfd_reloc_overflow:
 	default:
 	  {
-	    const char *name;
+	    char *name;
 
 	    if (h)
-	      name = h->root.root.string;
+	      {
+		const char *section = bfd_section_name
+		  (h->root.u.def.section->owner, h->root.u.def.section);
+		if (h->root.u.def.section->owner->my_archive)
+		  {
+		    const char *archive = bfd_get_filename
+		      (h->root.u.def.section->owner->my_archive);
+		    const char *member = bfd_get_filename
+		      (h->root.u.def.section->owner);
+		    name = alloca (sizeof ("`' defined in section  in ()")
+				   + strlen (h->root.root.string)
+				   + strlen (section)
+				   + strlen (archive)
+				   + strlen (member));
+		    sprintf (name, "`%s' defined in section %s in %s(%s)",
+			     h->root.root.string, section, archive,
+			     member);
+		  }
+		else
+		  {
+		    const char *file = bfd_get_filename 
+		      (h->root.u.def.section->owner);
+		    name = alloca (sizeof ("`' defined in section  in ")
+				   + strlen (h->root.root.string)
+				   + strlen (section) + strlen (file));
+		    sprintf (name, "`%s' defined in section %s in %s",
+			     h->root.root.string, section, file);
+		  }
+	      }
 	    else
 	      {
 		name = bfd_elf_string_from_elf_section (input_bfd,
@@ -4544,7 +4572,8 @@ elfNN_ia64_relocate_section (output_bfd,
 		if (name == NULL)
 		  return FALSE;
 		if (*name == '\0')
-		  name = bfd_section_name (input_bfd, input_section);
+		  name = (char *) bfd_section_name (input_bfd,
+						    input_section);
 	      }
 	    if (!(*info->callbacks->reloc_overflow) (info, name,
 						     howto->name,



More information about the Binutils mailing list