[binutils-gdb] Provide a more helpful error message when the BFD library is unable to load an extremely large secti

Nick Clifton nickc@sourceware.org
Thu Nov 10 12:27:00 GMT 2016


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a18590c38657a982f8d544f2f54f39ba9abe9fca

commit a18590c38657a982f8d544f2f54f39ba9abe9fca
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Nov 10 12:26:53 2016 +0000

    Provide a more helpful error message when the BFD library is unable to load an extremely large section.
    
    	PR target/20737
    	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Bind defined
    	symbol locally in PIE.

Diff:
---
 bfd/ChangeLog  | 6 ++++++
 bfd/compress.c | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9d97c64..abfda75 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -4,6 +4,12 @@
 	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Bind defined
 	symbol locally in PIE.
 
+2016-11-10  Nick Clifton  <nickc@redhat.com>
+
+	PR binutils/20801
+	* compress.c (bfd_get_full_section_contents): Provide a more
+	helpful error message when a section is too large to load.
+
 2016-11-08  Pedro Alves  <palves@redhat.com>
 
 	* dwarf2.c (struct funcinfo) <is_linkage>: Type is bfd_boolean,
diff --git a/bfd/compress.c b/bfd/compress.c
index 0a96630..95e8c23 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -247,7 +247,15 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
 	{
 	  p = (bfd_byte *) bfd_malloc (sz);
 	  if (p == NULL)
+	    {
+	      /* PR 20801: Provide a more helpful error message.  */
+	      if (bfd_get_error () == bfd_error_no_memory)
+		_bfd_error_handler
+		  /* xgettext:c-format */
+		  (_("error: %B(%A) is too large (%#lx bytes)"),
+		  abfd, sec, (long) sz);
 	    return FALSE;
+	    }
 	}
 
       if (!bfd_get_section_contents (abfd, sec, p, 0, sz))



More information about the Binutils-cvs mailing list