Bug 1674430

Summary: RFE: support reading compressed ELF objects
Product: Red Hat Enterprise Linux 8 Reporter: Panu Matilainen <pmatilai>
Component: elfutilsAssignee: Mark Wielaard <mjw>
elfutils sub component: system-version QA Contact: Martin Cermak <mcermak>
Status: CLOSED ERRATA Docs Contact: Vladimír Slávik <vslavik>
Severity: unspecified    
Priority: unspecified CC: dsmith, mcermak, mjw, mnewsome
Version: 8.0   
Target Milestone: rc   
Target Release: 8.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: elfutils-0.176-1.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-05 22:18:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1682591, 1683705    
Bug Blocks: 1650074, 1701002    

Description Panu Matilainen 2019-02-11 10:50:12 UTC
Description of problem:

From the description of bug 1650074:
> 
> There are no /usr/lib/.build-id /usr/lib/debug/.build-id
> links for kernel modules in kernel rpms like there used to be.
> 
> The problem seems to be in rpmbuild which is not able to
> read compressed kernel module files and wouldn't add their
> .build-id links to the rpm.
> 
> Solution was discussed with Mark Wielaard to used elfutils 0.175
> which supports compressed elf objects via dwelf_elf_begin:
> 
> > /* Creates a read-only Elf handle from the given file handle.  The
> >    file may be compressed and/or contain a linux kernel image header,
> >    in which case it is eagerly decompressed in full and the Elf handle
> >    is created as if created with elf_memory ().  On error NULL is
> >    returned.  The Elf handle should be closed with elf_end ().  The
> >    file handle will not be closed.  Does not return ELF_K_NONE
> > handles.  */
> > extern Elf *dwelf_elf_begin (int fd);
> 
> elfutils 0.175 should be released shortly.

Elfutils rebase (or backport of the feature) is needed to fix this in rpm, this bug is for tracking the elfutils side of things.

Comment 1 Mark Wielaard 2019-05-10 20:24:33 UTC
The elfutils 0.176 rebase provides the new dwelf_elf_begin () function.

Comment 3 Mark Wielaard 2019-05-21 09:18:26 UTC
For testing purposes you could of course look to see that dwelf_elf_begin is now in libdwelf.h and libdw.so.
Also eu-readelf now takes advantage of dwelf_elf_begin() to directly read compressed ELF files.
An example are linux kernel modules. Take for example a random one like:
/usr/lib/modules/3.10.0-957.12.2.el7.x86_64/kernel/fs/xfs/xfs.ko.xz

Before this change:
$ eu-readelf -n xfs.ko.xz 
eu-readelf: cannot create EBL handle
$ echo $?
1

After this change:
$ eu-readelf -n xfs.ko.xz 

Note section [ 1] '.note.gnu.build-id' of 36 bytes at offset 0x40:
  Owner          Data size  Type
  GNU                   20  GNU_BUILD_ID
    Build ID: 57949197896368b658cc27fd62191a7ca345826c
$ echo $?
0

Comment 6 errata-xmlrpc 2019-11-05 22:18:00 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.

https://access.redhat.com/errata/RHSA-2019:3575