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 v2] _bfd_mips_elf_final_link: notify user about wrong .reginfo size


One of assertions in _bfd_mips_elf_final_link could be triggered by
a combination of input files and a linker script.  This happens when
either the input doesn't contain .reginfo section or when this section
is oversized.  This patch replaces the assertion with a more useful
error message.

	* elfxx-mips.c (_bfd_mips_elf_final_link): Notify user when
	.reginfo section has wrong size.
---
 bfd/ChangeLog    |  5 +++++
 bfd/elfxx-mips.c | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a174a4cfeb..ea030def01 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -13,6 +13,11 @@
 
 	Update year range in copyright notice of all files.
 
+2018-01-09  Vlad Ivanov  <vlad@ivanov.email>
+
+	* elfxx-mips.c (_bfd_mips_elf_final_link): Notify user when
+	.reginfo section has wrong size.
+
 For older changes see ChangeLog-2017
 
 Copyright (C) 2018 Free Software Foundation, Inc.
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 3ef98af500..fc49f2f69a 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -14374,7 +14374,15 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info)
 	    }
 
 	  /* 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))
+	    {
+	      _bfd_error_handler
+		(_("%B: .reginfo section size should be %d bytes, "
+		   "actual size is %d"),
+		 abfd, sizeof (Elf32_External_RegInfo), o->size);
+
+	      return FALSE;
+	    }
 
 	  /* Skip this section later on (I don't think this currently
 	     matters, but someday it might).  */
-- 
2.14.3


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