Enable eu-stacktrace on x86_64
Add elfutils-0.192-stacktrace-lto.patch

Resolves: RHEL-64067
This commit is contained in:
Aaron Merey 2024-10-24 18:45:03 -04:00
parent e1311a3451
commit c06d0b7bcf
2 changed files with 64 additions and 4 deletions

View File

@ -0,0 +1,35 @@
commit 43829fb8780ecbe9d17aaed22d3dfcb806cb5f45
Author: Mark Wielaard <mark@klomp.org>
Date: Thu Oct 24 10:44:25 2024 +0200
stacktrace: Init elf_fd in sysprof_init_dwfl
When building with LTO gcc believes elf_fd can be used uninitialized:
In function sysprof_init_dwfl,
inlined from sysprof_unwind_cb at stacktrace.c:1235:16:
stacktrace.c:1087:7: error: elf_fd may be used uninitialized [-Werror=maybe-uninitialized]
1087 | close (elf_fd);
| ^
This code won't be reached because if find_procfile doesn't initialize
elf_fd, it will return an error. But help the compiler by initializing
elf_fd to -1.
* src/stacktrace.c (sysprof_init_dwfl): Init elf_fd to -1.
Signed-off-by: Mark Wielaard <mark@klomp.org>
diff --git a/src/stacktrace.c b/src/stacktrace.c
index 438cb1dd0d38..b912ca5de502 100644
--- a/src/stacktrace.c
+++ b/src/stacktrace.c
@@ -1033,7 +1033,7 @@ sysprof_init_dwfl (struct sysprof_unwind_info *sui,
}
Elf *elf = NULL;
- int elf_fd;
+ int elf_fd = -1;
err = find_procfile (dwfl, &pid, &elf, &elf_fd);
if (err < 0)
{

View File

@ -4,7 +4,7 @@
Name: elfutils Name: elfutils
Version: 0.192 Version: 0.192
%global baserelease 1 %global baserelease 2
Release: %{baserelease}%{?dist} Release: %{baserelease}%{?dist}
URL: http://elfutils.org/ URL: http://elfutils.org/
%global source_url ftp://sourceware.org/pub/elfutils/%{version}/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/
@ -16,6 +16,13 @@ Summary: A collection of utilities and DSOs to handle ELF files and DWARF data
# Needed for isa specific Provides and Requires. # Needed for isa specific Provides and Requires.
%global depsuffix %{?_isa}%{!?_isa:-%{_arch}} %global depsuffix %{?_isa}%{!?_isa:-%{_arch}}
# eu-stacktrace currently only supports x86_64
%ifarch x86_64
%global enable_stacktrace 1
%else
%global enable_stacktrace 0
%endif
Requires: elfutils-libelf%{depsuffix} = %{version}-%{release} Requires: elfutils-libelf%{depsuffix} = %{version}-%{release}
Requires: elfutils-libs%{depsuffix} = %{version}-%{release} Requires: elfutils-libs%{depsuffix} = %{version}-%{release}
Requires: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release} Requires: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release}
@ -53,6 +60,11 @@ BuildRequires: curl
# For run-debuginfod-response-headers.sh test case # For run-debuginfod-response-headers.sh test case
BuildRequires: socat BuildRequires: socat
# For eu-stacktrace
%if %{enable_stacktrace}
BuildRequires: sysprof-capture-devel
%endif
BuildRequires: automake BuildRequires: automake
BuildRequires: autoconf BuildRequires: autoconf
BuildRequires: gettext-devel BuildRequires: gettext-devel
@ -77,6 +89,9 @@ BuildRequires: gettext-devel
# Include libeu.a objects in libelf.a for static linking. # Include libeu.a objects in libelf.a for static linking.
Patch1: elfutils-0.192-libelf-static.patch Patch1: elfutils-0.192-libelf-static.patch
# Fix eu-stacktrace LTO build error.
Patch2: elfutils-0.192-stacktrace-lto.patch
%description %description
Elfutils is a collection of utilities, including stack (to show Elfutils is a collection of utilities, including stack (to show
backtraces), nm (for listing symbols from object files), size backtraces), nm (for listing symbols from object files), size
@ -303,11 +318,14 @@ RPM_OPT_FLAGS="${RPM_OPT_FLAGS} -Wformat"
trap 'cat config.log' EXIT trap 'cat config.log' EXIT
%configure CFLAGS="$RPM_OPT_FLAGS" \
%if 0%{?centos} >= 8 %if 0%{?centos} >= 8
%configure CFLAGS="$RPM_OPT_FLAGS" --enable-debuginfod-urls=https://debuginfod.centos.org/ --enable-debuginfod-urls=%{dist_debuginfod_url} \
%else
%configure CFLAGS="$RPM_OPT_FLAGS"
%endif %endif
%if %{enable_stacktrace}
--enable-stacktrace \
%endif
--enable-debuginfod
trap '' EXIT trap '' EXIT
%make_build %make_build
@ -390,6 +408,9 @@ fi
%{_bindir}/eu-size %{_bindir}/eu-size
%{_bindir}/eu-srcfiles %{_bindir}/eu-srcfiles
%{_bindir}/eu-stack %{_bindir}/eu-stack
%if %{enable_stacktrace}
%{_bindir}/eu-stacktrace
%endif
%{_bindir}/eu-strings %{_bindir}/eu-strings
%{_bindir}/eu-strip %{_bindir}/eu-strip
%{_bindir}/eu-unstrip %{_bindir}/eu-unstrip
@ -497,6 +518,10 @@ exit 0
%systemd_postun_with_restart debuginfod.service %systemd_postun_with_restart debuginfod.service
%changelog %changelog
* Thu Oct 24 2024 Aaron Merey <amerey@redhat.com> - 0.192-2
- Enable eu-stacktrace on x86_64
- Add elfutils-0.192-stacktrace-lto.patch
* Wed Oct 23 2024 Aaron Merey <amerey@redhat.com> - 0.192-1 * Wed Oct 23 2024 Aaron Merey <amerey@redhat.com> - 0.192-1
- Upgrade to upstream elfutils 0.192 - Upgrade to upstream elfutils 0.192
- Drop upstreamed patches - Drop upstreamed patches