[PATCH v2] _bfd_mips_elf_final_link: notify user about wrong .reginfo size

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH v2] _bfd_mips_elf_final_link: notify user about wrong .reginfo size

Vlad Ivanov
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  <[hidden 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

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] _bfd_mips_elf_final_link: notify user about wrong .reginfo size

Maciej W. Rozycki-2
Hi Vlad,

 Thank you for the updated patch.  I have updated its heading to have the
sentence capitalised as I previously requested, i.e.:

_bfd_mips_elf_final_link: Notify user about wrong .reginfo size

and committed your change.  When submitting further changes please omit
any ChangeLog updates from the patch itself as they tend to apply wrongly
or not at all; the committer will extract entries from the description and
apply them where appropriate (also in the future we may have a GIT hook to
do that automatically).

 This change was small enough not to require a legal procedure to be
followed before it could be accepted for inclusion.  If you wish to
continue contributing to our project, then please let me know and I will
tell you what to do next.

 Thank you for your contribution.  I will follow up with test cases soon.

  Maciej