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: [PATCH, MIPS] More meaningful error message on small-data overflow


Adam Nemet <anemet@caviumnetworks.com> writes:
> Here is the new version.  OK?

Actually, it was incomplete.  I needed to handle R_MIPS_LITERAL
similarly to GPREL16.

For a while I also thought that I would need to add similar code to
_bfd_elf_mips_get_relocated_section_contents.  It turns out that this
hook is only used if the target changes during linking and the output
target does not define a custom final_link function to handle the
relocations (e.g. when using output format srec).  In this case we
have no access to the elf-mips-specific link table so we can't track
whether the error was already printed so I decided not to do it.
Therefore, this error message only works if the output format is also
ELF but I don't think this is big loss.

Is the new version OK?

Adam


	* elfxx-mips.c (struct mips_elf_link_hash_table): Add new field
	small_data_overflow_reported.
	(_bfd_mips_elf_link_hash_table_create): Initialize it.
	(_bfd_mips_elf_relocate_section) <bfd_reloc_overflow>: Report
	small-data section overflow.

Index: elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.211
diff -F^\([(a-zA-Z0-9_]\|#define\) -u -p -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.211 elfxx-mips.c
--- elfxx-mips.c	3 Jul 2007 14:26:42 -0000	1.211
+++ elfxx-mips.c	22 Jul 2007 06:14:58 -0000
@@ -325,6 +325,8 @@ struct mips_elf_link_hash_table
   bfd_boolean mips16_stubs_seen;
   /* True if we're generating code for VxWorks.  */
   bfd_boolean is_vxworks;
+  /* True if we already reported the small-data section overflow.  */
+  bfd_boolean small_data_overflow_reported;
   /* Shortcuts to some dynamic sections, or NULL if they are not
      being used.  */
   asection *srelbss;
@@ -8032,7 +8034,21 @@ _bfd_mips_elf_relocate_section (bfd *out
 	    ;
 	  else
 	    {
+	      struct mips_elf_link_hash_table *htab;
+
+	      htab = mips_elf_hash_table (info);
 	      BFD_ASSERT (name != NULL);
+	      if (!htab->small_data_overflow_reported
+		  && (howto->type == R_MIPS_GPREL16
+		      || howto->type == R_MIPS_LITERAL))
+		{
+		  const char *msg =
+		    _("small-data section exceeds 64KB;"
+		      " lower small-data size limit (see option -G)");
+
+		  htab->small_data_overflow_reported = TRUE;
+		  (*info->callbacks->einfo) ("%P: %s\n", msg);
+		}
 	      if (! ((*info->callbacks->reloc_overflow)
 		     (info, NULL, name, howto->name, (bfd_vma) 0,
 		      input_bfd, input_section, rel->r_offset)))
@@ -10174,6 +10190,7 @@ _bfd_mips_elf_link_hash_table_create (bf
   ret->rld_value = 0;
   ret->mips16_stubs_seen = FALSE;
   ret->is_vxworks = FALSE;
+  ret->small_data_overflow_reported = FALSE;
   ret->srelbss = NULL;
   ret->sdynbss = NULL;
   ret->srelplt = NULL;


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