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]

[PATCH, MIPS] Better diagnostic on incorrect size for .reginfo


This is fairly easy to trigger with a custom linker script and we
print an assert.  I am changing this into a hopefully more descriptive
error message.

Here is for example what one of our customers was doing:

  SECTIONS
  {
    .text    ALIGN(4) : { *(.text) }
    .data    ALIGN(8) : { *(.data) }
    .reginfo .        : { *(.reginfo) }
  }

(Note the dot after .reginfo.)  .reginfo is 8-byte aligned on n32.  If
dot is not aligned before .reginfo, the start of the section is set to
the unaligned address and then padding is added which increases the
size of the output section.

After the patch there is a slight change in behavior because
BFD_ASSERT allows the linking to continue whereas I make it fail now.
I would think this is better.

OK?

Adam

	* elfxx-mips.c (_bfd_mips_elf_final_link): Report error instead of
	BFD_ASSERT if size of .reginfo is incorrect.

Index: elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.212
diff -F^\([(a-zA-Z0-9_]\|#define\) -u -p -r1.212 elfxx-mips.c
--- elfxx-mips.c	22 Jul 2007 16:45:06 -0000	1.212
+++ elfxx-mips.c	14 Aug 2007 18:58:34 -0000
@@ -10383,7 +10383,15 @@ _bfd_mips_elf_final_link (bfd *abfd, str
 	    }
 
 	  /* Size has been set in _bfd_mips_elf_always_size_sections.  */
-	  BFD_ASSERT(o->size == sizeof (Elf32_External_RegInfo));
+	  if (o->size != sizeof (Elf32_External_RegInfo))
+	    {
+	      const char *msg =
+		_("%F%B: .reginfo is %lu bytes instead of %u bytes\n");
+
+	      info->callbacks->einfo
+		(msg, abfd, (unsigned long) o->size,
+		 (unsigned) sizeof (Elf32_External_RegInfo));
+	    }
 
 	  /* Skip this section later on (I don't think this currently
 	     matters, but someday it might).  */


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