Bug 472152

Summary: ld --build-id checksum omits section contents
Product: [Fedora] Fedora Reporter: Roland McGrath <roland>
Component: binutilsAssignee: Nick Clifton <nickc>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: medium    
Version: 9CC: jakub, jan.kratochvil, nickc
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-11-29 07:57:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
load section contents if necessary none

Description Roland McGrath 2008-11-19 00:16:14 UTC
Description of problem:


Version-Release number of selected component (if applicable):

binutils-2.18.50.0.6-6.fc9.x86_64

How reproducible:

100%

Steps to Reproduce:
1.echo 'main(){}' > a.c; cp a.c b.c
2.gcc -g -o a a.c; gcc -g -o b b.c
3.eu-readelf -n a b
  
Actual results:

build ID bits (shown in hex by eu-readelf) match

Expected results:

build ID bits should not match

Additional info:

bfd/elfcode.h:elf_checksum_contents is responsible for feeding the contents about to be written into the checksum calculation to produce the ID.  Debugging shows that i_shdr.contents==0 for all the sections.  The original intent of that code was to get all the nonempty sections' contents, maybe except for the build-id section itself (either it won't have contents yet and gets skipped, or its contents bytes are all zero and those feed into the sum, either is fine).  I don't think this was broken when originally implemented, so something has changed so that the .contents field is not set to the in-memory contents buffer in this case as the code expects.

Note this bug does not affect RPM package builds, because rpmbuild's debugedit recomputes build ID bits itself with separate code that doesn't have this bug.

Comment 1 Nick Clifton 2008-11-26 13:44:34 UTC
Created attachment 324713 [details]
load section contents if necessary

Comment 2 Nick Clifton 2008-11-26 13:45:28 UTC
Hi Roland,

  Please could you try the uploaded patch and let me know if it works for you.

Cheers
  Nick

Comment 3 Roland McGrath 2008-11-26 19:40:00 UTC
Works for me.

Comment 4 Nick Clifton 2008-11-29 07:57:21 UTC
I have checked in the patch to the rawhide sources.