This is the mail archive of the 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]

Commit: PR 22587:

Hi Guys,

  I am applying the patch below as a fix for PR 22587.
  The issue was that readelf used to complain about relocation sections 
  in dynamic executables having an sh_info value of 0.  Since these
  relocations do not reference sections, this does not matter, and
  readelf's warning was wrong.


2017-12-19  Nick Clifton  <>

	PR 22587
	* readelf.c (process_section_headers): Do not complain about an
	sh_info field of 0 in relocation sections of ET_EXEC or ET_DYN
	type executables.

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 8a31ebbd07..c6070f276d 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -6268,12 +6268,15 @@ process_section_headers (Filedata * filedata)
 		  && filedata->section_headers[section->sh_info].sh_type < SHT_LOOS))
 	      if (section->sh_info == 0
-		  && (streq (SECTION_NAME (section), ".rel.dyn")
+		  && (filedata->file_header.e_type == ET_EXEC
+		      || filedata->file_header.e_type == ET_DYN
+		      /* These next two tests may be redundant, but
+			 they have been left in for paranoia's sake.  */
+		      || streq (SECTION_NAME (section), ".rel.dyn")
 		      || streq (SECTION_NAME (section), ".rela.dyn")))
-		/* The .rel.dyn and .rela.dyn sections have an sh_info field
-		   of zero.  The relocations in these sections may apply
-		   to many different sections.  */
-		   ;
+		/* Dynamic relocations apply to segments, not sections, so
+		   they do not need an sh_info value.  */
+		;
 		warn (_("[%2u]: Info field (%u) should index a relocatable section.\n"),
 		      i, section->sh_info);

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