Bug 472152 - ld --build-id checksum omits section contents
Summary: ld --build-id checksum omits section contents
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: 9
Hardware: All
OS: Linux
medium
high
Target Milestone: ---
Assignee: Nick Clifton
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-11-19 00:16 UTC by Roland McGrath
Modified: 2008-11-29 07:57 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-11-29 07:57:21 UTC
Type: ---
Embargoed:


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

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.


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