Bug 472152 - ld --build-id checksum omits section contents
ld --build-id checksum omits section contents
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: binutils (Show other bugs)
9
All Linux
medium Severity high
: ---
: ---
Assigned To: Nick Clifton
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-18 19:16 EST by Roland McGrath
Modified: 2008-11-29 02:57 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-11-29 02:57:21 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
load section contents if necessary (632 bytes, patch)
2008-11-26 08:44 EST, Nick Clifton
no flags Details | Diff

  None (edit)
Description Roland McGrath 2008-11-18 19:16:14 EST
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 08:44:34 EST
Created attachment 324713 [details]
load section contents if necessary
Comment 2 Nick Clifton 2008-11-26 08:45:28 EST
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 14:40:00 EST
Works for me.
Comment 4 Nick Clifton 2008-11-29 02:57:21 EST
I have checked in the patch to the rawhide sources.

Note You need to log in before you can comment on or make changes to this bug.