libdrgn: orc_info: work around ORC backports in RHEL 9.6

Resolves: RHEL-136527
Upstream: https://github.com/osandov/drgn

This problem is fixed in the kernel with b9f174c811e3 ("x86/unwind/orc:
Add ELF section with ORC version identifier"). But the fix won't work as
expected due to missing commit 321648455061 ("kbuild: use obj-y instead
extra-y for objects placed at the head"). The second commit however is
very invasive and shouldn't be backported this late in the RHEL9 cycle
(see RHEL-27234 for details). So backport the workaround in drgn
instead.

commit 8660ee186377aabf28cd54d76beb942b9a06d09a
Author: Stephen Brennan <stephen.s.brennan@oracle.com>
Date:   Fri Dec 5 10:43:44 2025 -0800

    libdrgn: orc_info: work around ORC backports in RHEL 9.6

    Add a special case to detect RHEL 9 kernel versions since release
    5.14.0-517.el9, and use ORC "v3" for these kernels.

    Fixes #578.

    Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>

Signed-off-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Philipp Rudo 2025-12-17 14:40:28 +01:00
parent 7fddd23252
commit 395e648256
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,44 @@
From 8660ee186377aabf28cd54d76beb942b9a06d09a Mon Sep 17 00:00:00 2001
From: Stephen Brennan <stephen.s.brennan@oracle.com>
Date: Fri, 5 Dec 2025 10:43:44 -0800
Subject: [PATCH] libdrgn: orc_info: work around ORC backports in RHEL 9.6
Add a special case to detect RHEL 9 kernel versions since release
5.14.0-517.el9, and use ORC "v3" for these kernels.
Fixes #578.
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
---
libdrgn/orc_info.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/libdrgn/orc_info.c b/libdrgn/orc_info.c
index 7015d096..83ea3f4e 100644
--- a/libdrgn/orc_info.c
+++ b/libdrgn/orc_info.c
@@ -254,6 +254,21 @@ static int orc_version_from_osrelease(struct drgn_program *prog)
long minor = 0;
if (*p == '.')
minor = strtol(p + 1, NULL, 10);
+
+ // RHEL & derivatives started shipping backported ORC patches without
+ // the ".orc_header" section in 9.6. According to git history this was
+ // introduced in kernel version 5.14.0-517.el9. With those changes, the
+ // kernel's ORC "format" is indeed v3, but we cannot detect that without
+ // the ORC header hash. Add special-case detection for this situation.
+ // If it is fixed by including the ".orc_header" section, this fix will
+ // not be active, but will still be necessary for the already released
+ // kernels.
+ char *rhrelease = NULL;
+ if (major == 5 && minor == 14 && strstr(p, ".el9")
+ && (rhrelease = strchr(p, '-'))
+ && strtol(rhrelease + 1, NULL, 10) >= 517)
+ return 3;
+
if (major > 6 || (major == 6 && minor >= 4))
return 3;
else if (major == 6 && minor == 3)
--
2.52.0

View File

@ -15,7 +15,7 @@ scripting in Python.}
Name: python-%{pypi_name}
Version: 0.0.33
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Programmable debugger
License: LGPL-2.1-or-later
@ -46,6 +46,8 @@ BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
Patch001: 0001-libdrgn-orc_info-work-around-ORC-backports-in-RHEL-9.patch
%description %{_description}
%package -n %{pypi_name}
@ -125,6 +127,10 @@ cp -PR man/drgn.1* %{buildroot}%{_mandir}/man1
%endif
%changelog
* Wed Dec 17 2025 Philipp Rudo <prudo@redhat.com> - 0.0.33-2
- Work around ORC backports in RHEL 9.6
Resolves: RHEL-136527
* Thu Nov 13 2025 Philipp Rudo <prudo@redhat.com> - 0.0.33-1
- Rebase to upstream v0.0.33
Resolves: RHEL-114118