This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR ld/12451: --build-id doesn't work
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org, Jakub Jelinek <jakub at redhat dot com>
- Cc: Nick Clifton <nickc at redhat dot com>
- Date: Tue, 13 Dec 2011 16:01:03 -0800
- Subject: PATCH: PR ld/12451: --build-id doesn't work
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
As Jakub points out in
http://sourceware.org/bugzilla/show_bug.cgi?id=12451#c1
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?
Thanks.
H.J.
---
2011-12-14 Nick Clifton <nickc@redhat.com>
Jakub Jelinek <jakub@redhat.com>
PR ld/12451
* elfcode.h (elf_checksum_contents): Load section contents if
needed.
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;