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]

PATCH: PR ld/12451: --build-id doesn't work

As Jakub points out in

Actually, it seems upstream binutils probably never handled it right and
it seems Fedora had some local patch for it that got dropped as redundant
when it actually has never been redundant.  In elf_checksum_contents it
checksums contents of sections guarded with if (i_shdr.contents)
Except, at least in my testing, i_shdr.contents is always NULL so it
only checksums section headers, program headers and ELF header.

I don't believe we always set i_shdr.contents for output binary.  Here
is the patch from Fedora binutils.  OK to install?


2011-12-14  Nick Clifton  <>
	    Jakub Jelinek  <> 

	PR ld/12451
	* elfcode.h (elf_checksum_contents): Load section contents if

diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index b7e0226..5c06bae 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -1099,6 +1099,24 @@ elf_checksum_contents (bfd *abfd,
       if (i_shdr.contents)
 	(*process) (i_shdr.contents, i_shdr.sh_size, arg);
+      else
+	{
+	  asection *sec;
+	  sec = bfd_section_from_elf_index (abfd, count);
+	  if (sec != NULL)
+	    {
+	      if (sec->contents == NULL)
+		{
+		  /* Force rereading from file.  */
+		  sec->flags &= ~SEC_IN_MEMORY;
+		  if (! bfd_malloc_and_get_section (abfd, sec, & sec->contents))
+		    continue;
+		}
+	      if (sec->contents != NULL)
+		(*process) (sec->contents, i_shdr.sh_size, arg);
+	    }
+	}
   return TRUE;

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