Nick Clifton 3b2ebb
diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c
Nick Clifton 3b2ebb
--- binutils.orig/binutils/readelf.c	2017-03-20 17:06:41.260789454 +0000
Nick Clifton 3b2ebb
+++ binutils-2.28/binutils/readelf.c	2017-03-20 17:08:09.181289807 +0000
Nick Clifton 3b2ebb
@@ -4965,12 +4965,6 @@ process_program_headers (FILE * file)
Nick Clifton 3b2ebb
 	     section in the DYNAMIC segment.  */
Nick Clifton 3b2ebb
 	  dynamic_addr = segment->p_offset;
Nick Clifton 3b2ebb
 	  dynamic_size = segment->p_filesz;
Nick Clifton 3b2ebb
-	  /* PR binutils/17512: Avoid corrupt dynamic section info in the segment.  */
Nick Clifton 3b2ebb
-	  if (dynamic_addr + dynamic_size >= current_file_size)
Nick Clifton 3b2ebb
-	    {
Nick Clifton 3b2ebb
-	      error (_("the dynamic segment offset + size exceeds the size of the file\n"));
Nick Clifton 3b2ebb
-	      dynamic_addr = dynamic_size = 0;
Nick Clifton 3b2ebb
-	    }
Nick Clifton 3b2ebb
 
Nick Clifton 3b2ebb
 	  /* Try to locate the .dynamic section. If there is
Nick Clifton 3b2ebb
 	     a section header table, we can easily locate it.  */
Nick Clifton 3b2ebb
@@ -5005,6 +4999,16 @@ process_program_headers (FILE * file)
Nick Clifton 3b2ebb
 		warn (_("the .dynamic section is not the first section"
Nick Clifton 3b2ebb
 			" in the dynamic segment.\n"));
Nick Clifton 3b2ebb
 	    }
Nick Clifton 3b2ebb
+
Nick Clifton 3b2ebb
+	  /* PR binutils/17512: Avoid corrupt dynamic section info in the
Nick Clifton 3b2ebb
+	     segment.  Check this after matching against the section headers
Nick Clifton 3b2ebb
+	     so we don't warn on debuginfo file (which have NOBITS .dynamic
Nick Clifton 3b2ebb
+	     sections).  */
Nick Clifton 3b2ebb
+	  if (dynamic_addr + dynamic_size >= current_file_size)
Nick Clifton 3b2ebb
+	    {
Nick Clifton 3b2ebb
+	      error (_("the dynamic segment offset + size exceeds the size of the file\n"));
Nick Clifton 3b2ebb
+	      dynamic_addr = dynamic_size = 0;
Nick Clifton 3b2ebb
+	    }
Nick Clifton 3b2ebb
 	  break;
Nick Clifton 3b2ebb
 
Nick Clifton 3b2ebb
 	case PT_INTERP: