Bug 1924068

Summary: binutils debuginfo misses code for bfd functions
Product: Red Hat Enterprise Linux 8 Reporter: Michael Petlan <mpetlan>
Component: binutilsAssignee: Nick Clifton <nickc>
binutils sub component: system-version QA Contact: Miloš Prchlík <mprchlik>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: fweimer, mprchlik, ohudlick
Version: 8.4Keywords: Bugfix, Triaged
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: binutils-2.30-100.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 19:31:20 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:

Description Michael Petlan 2021-02-02 14:26:57 UTC
Description of problem:

There seems to be no debuginfo for functions from libbfd.so (installed by binutils package) in binutils-debuginfo and binutils-debugsource packages.

Version-Release number of selected component (if applicable):
binutils-debuginfo-2.30-90.el8.aarch64

How reproducible:
100%

Steps to Reproduce:
1. try to debug something that uses bfd (e.g. perf-4.18.0-280.el8 and newer):

yum -y install perf
debuginfo-install -y perf binutils
... install all the debuginfo packages gdb suggests you to install

run perf under gdb:
gdb /usr/bin/perf -ex 'b bfd_check_format' -ex "r test -F 'PE file'"

run "bt" command after reaching the breakpoint

Actual results:

(gdb) bt
#0  0x0000aaaaaad4edcc in bfd_check_format ()
#1  0x0000aaaaaaceade4 in filename__read_build_id (filename=filename@entry=0xffffffff90e8 "/usr/libexec/perf-core/tests/pe-file.exe", bid=bid@entry=0xffffffff90b0) at util/symbol-elf.c:547
#2  0x0000aaaaaac25448 in run_dir (d=d@entry=0xffffffffd1a8 "/usr/libexec/perf-core/tests") at tests/pe-file-parsing.c:39
#3  0x0000aaaaaac25780 in test__pe_file_parsing (test=<optimized out>, subtest=<optimized out>) at tests/pe-file-parsing.c:85
#4  0x0000aaaaaabfa3a4 in run_test (subtest=-1, test=0xaaaaab06fff8 <generic_tests+4288>) at tests/builtin-test.c:418
#5  test_and_print (t=t@entry=0xaaaaab06fff8 <generic_tests+4288>, force_skip=force_skip@entry=false, subtest=subtest@entry=-1) at tests/builtin-test.c:448
#6  0x0000aaaaaabfb4dc in __cmd_test (skiplist=0x0, argv=0xffffffffe940, argc=1) at tests/builtin-test.c:669
#7  cmd_test (argc=1, argv=0xffffffffe940) at tests/builtin-test.c:815
#8  0x0000aaaaaac2695c in run_builtin (p=0xaaaaab0702e0 <commands+552>, argc=3, argv=0xffffffffe940) at perf.c:312
#9  0x0000aaaaaab9c6f8 in handle_internal_command (argv=0xffffffffe940, argc=3) at perf.c:364
#10 run_argv (argcp=<synthetic pointer>, argv=<synthetic pointer>) at perf.c:408
#11 main (argc=<optimized out>, argv=0xffffffffe940) at perf.c:538



Expected results:

There should be debuginfo for bfd_check_format() function as well.

Additional info:

Comment 1 Nick Clifton 2021-02-04 14:13:21 UTC
Hi Micahel,

  This is a strange one.  The binutils-debuginfo rpm does exist, and it does contain debug information for some functions, but not all.  GCC is responsible for generating the debug info and I am wondering if this is an artifact of the recent adoption of LTO compilation by default ...

 Cheers
  Nick

Comment 2 Nick Clifton 2021-02-04 15:16:06 UTC
OK, I have found the problem, but not the cause.  The static version of the bfd library (libbfd.a) contains object files that are stripped of debug information.  This looks like a build issue.

Investigating....

Comment 3 Jeff Law 2021-02-04 19:09:14 UTC
So one of the things I'd recommend is looking at the libbfd.a in the build directory ie /build/builddir/BUILD first to see if it has the debuginfo.  Then I'd look at the install directory (/build/builddir/BUILDROOT) to see if it was stripped away.

Or it might just be a case where optimizing with LTO is losing some of the debuginfo.  I could see that happening with aggressive inlining at LTO time, though it's *supposed* to work with debuginfo generation.

Comment 4 Florian Weimer 2021-02-04 19:18:05 UTC
Is this about the static library?

All installed *.a libraries are stripped, so that linking with them produces stripped binaries. I proposed to change that in

  <https://fedoraproject.org/wiki/Changes/StaticLibraryDebuginfo>

but it was rejected.

Comment 5 Nick Clifton 2021-02-05 10:33:20 UTC
(In reply to Florian Weimer from comment #4)
> Is this about the static library?

Yes - this is exactly the problem.

> All installed *.a libraries are stripped, so that linking with them produces
> stripped binaries. I proposed to change that in

Michael - this is the source of the problem.  The RHEL build system strips debug information from static archives and perf is linked against the static bfd library.

Since *all* apps that use the bfd library are forced to link against the static version (the libbfd.so file is just a linker script fragement that causes the static version to be used) I have gone ahead and created a patch to the binutils.spec file that disables the debug info stripping.  The patch is currently in rawhide (binutils-2.35.1-33.fc34) and it will be in RHEL-9 shortly.  I do not however plan on updating binutils for RHEL-8.4.0  Instead I think that it would be better to fix this in RHEL-8.5.0.

Comment 7 Nick Clifton 2021-03-24 11:57:59 UTC
Fixed in binutils-2.30-98.el8.

Comment 13 Miloš Prchlík 2021-04-29 12:44:04 UTC
Verified with binutils-devel-2.30-101.el8.

Comment 16 errata-xmlrpc 2021-11-09 19:31:20 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 (Moderate: binutils security update), 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-2021:4364