Bug 806474

Summary: eu-unstrip unwilling to reassembled corrupted separate debuginfo
Product: Red Hat Enterprise Linux 6 Reporter: Frank Ch. Eigler <fche>
Component: elfutilsAssignee: Mark Wielaard <mjw>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3CC: acme, drepper, mbenitez, mcermak, mjw, syeghiay
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: elfutils-0.158-3.2.el6 Doc Type: Bug Fix
Doc Text:
Cause: There were bugs in some toolchain tools, see bug #698005, that could cause a main ELF file the separate debuginfo file to have different header types/flags. eu-unstrip would not combine such files. The same was true when the main ELF file was prelinked after the debuginfo was separated into a debug file. Consequence: The ELF file and the separate debug file could not be recombined into one with eu-unstrip. Fix: eu-unstrip now explains which header field doesn't match when it refuses to combine a stripped and unstripped file. e.g. "ELF header identification (e_ident) different." And also now has a --force option that will warn, but try to combine such files anyway. That works fine for ELF files produced with the buggy binutils from bug #698005. For prelinked stripped files it might work, but eu-unstrip also produces a warning if the DWARF data might need adjusting for prelinking bias (DWARF data in 'merged' not adjusted for prelinking bias; consider prelink -u). Result: Such mismatching main ELF and separate debug files can now be recombined into one using eu-unstrip, using the --force flag.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-14 06:42:24 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 Frank Ch. Eigler 2012-03-23 21:33:09 UTC
In bug #698005, it was found that binutils slightly deforms separate debuginfo files.  In order to make eu-unstrip work with existing RHEL6 binaries, a sanity check elfutils src/unstrip.c (handle_explicit_files memcmp of e_indent) that detects this deformation should be disabled.  We have a patch at hand to do this.  Without this fix, perf's mixed-source disassembly won't work for userspace programs.

Comment 1 Mark Wielaard 2012-03-26 12:15:57 UTC
There is more to this than just the e_ident check.
For example the e_phnum check is also failing in the case of bash-4.1.2-8.el6.x86_64 and bash-debuginfo-4.1.2-8.el6.x86_64 (9 in the binary, 8 in the debug file):

$ eu-readelf --file-header --program-headers /bin/bash /usr/lib/debug/bin/bash.debug

/bin/bash:

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Ident Version:                     1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           AMD x86-64
  Version:                           1 (current)
  Entry point address:               0x41aef0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          937776 (bytes into file)
  Flags:                             
  Size of this header:               64 (bytes)
  Size of program header entries:    56 (bytes)
  Number of program headers entries: 9
  Size of section header entries:    64 (bytes)
  Number of section headers entries: 32
  Section header string table index: 31

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  PHDR           0x000040 0x0000000000400040 0x0000000000400040 0x0001f8 0x0001f8 R E 0x8
  INTERP         0x000238 0x0000000000400238 0x0000000000400238 0x00001c 0x00001c R   0x1
	[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x000000 0x0000000000400000 0x0000000000400000 0x0d38dc 0x0d38dc R E 0x200000
  LOAD           0x0d38e0 0x00000000006d38e0 0x00000000006d38e0 0x008bf8 0x00e4c8 RW  0x200000
  LOAD           0x0dc4d8 0x00000000008dc4d8 0x00000000008dc4d8 0x008052 0x008052 RW  0x200000
  DYNAMIC        0x0d3908 0x00000000006d3908 0x00000000006d3908 0x0001b0 0x0001b0 RW  0x8
  NOTE           0x000254 0x0000000000400254 0x0000000000400254 0x000044 0x000044 R   0x4
  GNU_EH_FRAME   0x0bc76c 0x00000000004bc76c 0x00000000004bc76c 0x003a94 0x003a94 R   0x4
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x8

 Section to Segment mapping:
  Segment Sections...
   00     
   01      [RO: .interp]
   02      [RO: .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .gnu.liblist .gnu.conflict .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame]
   03      .ctors .dtors .jcr .dynamic .got .got.plt .data .dynbss .bss
   04      .dynstr
   05      .dynamic
   06      [RO: .note.ABI-tag .note.gnu.build-id]
   07      [RO: .eh_frame_hdr]
   08     

/usr/lib/debug/bin/bash.debug:

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Ident Version:                     1 (current)
  OS/ABI:                            Linux
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           AMD x86-64
  Version:                           1 (current)
  Entry point address:               0x41aef0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          1998960 (bytes into file)
  Flags:                             
  Size of this header:               64 (bytes)
  Size of program header entries:    56 (bytes)
  Number of program headers entries: 8
  Size of section header entries:    64 (bytes)
  Number of section headers entries: 39
  Section header string table index: 36

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  PHDR           0x000040 0x0000000000400040 0x0000000000400040 0x0001c0 0x0001c0 R E 0x8
  INTERP         0x000200 0x0000000000400200 0x0000000000400200 0x00001c 0x00001c R   0x1
	[Requesting program interpreter: ]
  LOAD           0x000000 0x0000000000400000 0x0000000000400000 0x0d38dc 0x0d38dc R E 0x200000
  LOAD           0x0d38e0 0x00000000006d38e0 0x00000000006d38e0 0x008ba0 0x00e4c8 RW  0x200000
  DYNAMIC        0x0d3908 0x00000000006d3908 0x00000000006d3908 0x0001b0 0x0001b0 RW  0x8
  NOTE           0x00021c 0x000000000040021c 0x000000000040021c 0x000044 0x000044 R   0x4
  GNU_EH_FRAME   0x0bc76c 0x00000000004bc76c 0x00000000004bc76c 0x003a94 0x003a94 R   0x4
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x8

 Section to Segment mapping:
  Segment Sections...
   00     
   01      [RO: .interp]
   02      [RO: .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame .comment .debug_aranges .debug_pubnames .debug_info .debug_abbrev .debug_line]
   03      .ctors .dtors .jcr .dynamic .got .got.plt .data .bss
   04      .dynamic
   05      [RO: .note.ABI-tag .note.gnu.build-id]
   06      [RO: .eh_frame_hdr]
   07

Comment 2 Suzanne Logcher 2012-03-30 18:30:00 UTC
This request was evaluated by Red Hat Product Management for inclusion in the
current release of Red Hat Enterprise Linux. Because the affected component is
not scheduled to be updated in the current release, Red Hat is unfortunately
unable to address this request at this time.  It has been proposed for the next
release. If you would like it considered as an exception in the current
release, please ask your support representative.

Comment 4 Frank Ch. Eigler 2012-07-30 17:41:48 UTC
pmachata advises problems likely fixed in 0.154

Comment 5 Mark Wielaard 2012-08-28 21:42:44 UTC
(In reply to comment #1)
> There is more to this than just the e_ident check.
> For example the e_phnum check is also failing in the case of
> bash-4.1.2-8.el6.x86_64 and bash-debuginfo-4.1.2-8.el6.x86_64 (9 in the
> binary, 8 in the debug file):
> 
> $ eu-readelf --file-header --program-headers /bin/bash
> /usr/lib/debug/bin/bash.debug

This is most likely:
"phdrs wrong in .debug file"
https://bugzilla.redhat.com/show_bug.cgi?id=849435

If so doing prelink -u on the main binary would "solve" that part.

Comment 6 RHEL Program Management 2012-09-07 05:09:53 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 24 Mark Wielaard 2014-05-28 11:11:35 UTC
eu-unstrip now explains which header field doesn't match when it refuses to combine a stripped and unstripped file. e.g. "ELF header identification (e_ident) different."

And also now has a --force option that will warn, but try to combine such files anyway. That works fine for ELF files produced with the buggy binutils from bug #698005. 

For prelinked stripped files it might work, but eu-unstrip also produces a warning if the DWARF data might need adjusting for prelinking bias (DWARF data in 'merged' not adjusted for prelinking bias; consider prelink -u).

Comment 27 errata-xmlrpc 2014-10-14 06:42:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2014-1472.html