Bug 249467

Summary: eu-readelf -n vs .debug files
Product: [Fedora] Fedora Reporter: Jan Kratochvil <jan.kratochvil>
Component: elfutilsAssignee: Roland McGrath <roland>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 0.131-1.fc7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-11-13 00:13:26 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:

Description Jan Kratochvil 2007-07-24 20:32:56 UTC
Description of problem:
eu-strip debug file separation corrupts the embedded build-id note.

Version-Release number of selected component (if applicable):
elfutils-0.128-2.fc7.x86_64

How reproducible:
Always.

Steps to Reproduce:
1. echo 'int main (void) { return 0; }' >main.c;gcc -o main main.c
-Wl,--build-id;echo ORIG;eu-readelf -a main|grep -A99 Owner;eu-strip
--strip-debug -f main.debug main;echo STRIPPED-BASE;eu-readelf -a main|grep -A99
Owner;echo STRIPPEd-DEBUG;eu-readelf -a main.debug|grep -A99 Owner

Actual results:
ORIG
  Owner          Data size  Type
  GNU                   16  VERSION
    OS: Linux, ABI: 2.6.9
  GNU                   20  <unknown>: 3
STRIPPED-BASE
  Owner          Data size  Type
  GNU                   16  VERSION
    OS: Linux, ABI: 2.6.9
  GNU                   20  <unknown>: 3
STRIPPEd-DEBUG
  Owner          Data size  Type
                        4  <unknown>: 20

Expected results:
ORIG
  Owner          Data size  Type
  GNU                   16  VERSION
    OS: Linux, ABI: 2.6.9
  GNU                   20  <unknown>: 3
STRIPPED-BASE
  Owner          Data size  Type
  GNU                   16  VERSION
    OS: Linux, ABI: 2.6.9
  GNU                   20  <unknown>: 3
STRIPPEd-DEBUG
  Owner          Data size  Type
  GNU                   16  VERSION
    OS: Linux, ABI: 2.6.9
  GNU                   20  <unknown>: 3

Additional info:

Comment 1 Roland McGrath 2007-07-24 20:48:51 UTC
There is no problem in eu-strip, just in eu-readelf.  It uses the phdrs instead
of sections to look for notes.  readelf (bintuils) will show you that the
contents are fine.  It's on my list to make eu-readelf handle notes in .debug
files, but it is not a big priority.

Comment 2 Jan Kratochvil 2007-07-25 18:43:58 UTC
ELF first pages in the core files have corrupted/missing SHDR as it just does
not fit there.  So one needs to locate NT_GNU_BUILD_ID from the core files by
PHDR only.  This cannot be changed.

But separate .debug files have only the corrupted (not updated) PHDR offsets 
while SHDR is right there.

Wouldn't it be best to implement/fix PHDR offsets updating in EU-STRIP?
The debug-id consumers now need a workaround to differentiate looking up the
build-id NOTE in the ELF main file from the core (PHDR) the ELF separate debug
file (SHDR).


Comment 3 Roland McGrath 2007-09-11 19:45:58 UTC
No, it's best that phdrs remain untouched by strip.

The proper procedure should be to use shdrs when available and phdrs when not.
When you have a partial or corrupt ELF file such that the shdrs are not usable,
then shdrs are not available, so don't use them.

Comment 4 Roland McGrath 2007-10-04 00:04:43 UTC
I have changed readelf upstream to use sections in preference to phdrs.
This should be fixed in 0.130.

Comment 5 Roland McGrath 2007-10-16 09:57:53 UTC
This issue should be resolved by elfutils-0.130.  If there is still a problem,
reopen or file a new bug report with complete test case details.

Comment 6 Fedora Update System 2007-10-18 02:30:52 UTC
elfutils-0.130-3.fc7 has been pushed to the Fedora 7 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update elfutils'

Comment 7 Fedora Update System 2007-11-13 00:13:20 UTC
elfutils-0.131-1.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.