Hello!

Please find attached the patch we have in Ubuntu to fix that issue.
From 014ab50e56a0e7c48069174de809a2bd58f0561c Mon Sep 17 00:00:00 2001
From: Pragyansh Chaturvedi <[email protected]>
Date: Fri, 6 Sep 2024 13:27:56 +0530
Subject: [PATCH 1/6]     - Add symbol dumps for bpftrace and bpftrace-aotrt   
    + d/helpers/dump_debug_symbols.sh: a shell script         to be used in
 d/rules to dump the debug symbols of bpftrace         and bpftrace-aotrt.    
   + d/rules: uses the shell script created by the above patch to         dump
 the debug symbols, which was not happening earlier due to         exclusion
 from dh_strip and custom strip commands.       (LP: #2069953)

---
 debian/helpers/dump_debug_symbols.sh | 15 +++++++++++++++
 debian/rules                         |  4 +++-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100755 debian/helpers/dump_debug_symbols.sh

diff --git a/debian/helpers/dump_debug_symbols.sh b/debian/helpers/dump_debug_symbols.sh
new file mode 100755
index 000000000000..e9c6fdfab569
--- /dev/null
+++ b/debian/helpers/dump_debug_symbols.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+process_file() {
+    local build_id=$(file --brief -e apptype -e ascii -e encoding -e cdf -e compress -e tar -- $1 | grep -oP 'BuildID\[sha1\]\s*=\s*\K[0-9a-f]+')
+
+    build_id_prefix=${build_id:0:2}
+    build_id_suffix=${build_id:2:38}
+
+    mkdir -p debian/.debhelper/bpftrace/dbgsym-root/usr/lib/debug/.build-id/$(echo "$build_id" | cut -c1-2)
+    objcopy --only-keep-debug --compress-debug-sections "$1" "debian/.debhelper/bpftrace/dbgsym-root/usr/lib/debug/.build-id/$build_id_prefix/$build_id_suffix.debug"
+    chmod 0644 "debian/.debhelper/bpftrace/dbgsym-root/usr/lib/debug/.build-id/$build_id_prefix/$build_id_suffix.debug"
+    objcopy --add-gnu-debuglink "debian/.debhelper/bpftrace/dbgsym-root/usr/lib/debug/.build-id/$build_id_prefix/$build_id_suffix.debug" "$1"
+}
+
+process_file $1
diff --git a/debian/rules b/debian/rules
index 89eeb4f6d192..13984420dac9 100755
--- a/debian/rules
+++ b/debian/rules
@@ -15,9 +15,11 @@ override_dh_auto_configure:
 
 STRIP_CMD=strip --keep-symbol=BEGIN_trigger --keep-symbol=END_trigger --remove-section=.comment --remove-section=.note
 override_dh_strip:
-	dh_strip -Xbpftrace -Xbpftrace-aotrt
+	debian/helpers/dump_debug_symbols.sh debian/bpftrace/usr/bin/bpftrace
+	debian/helpers/dump_debug_symbols.sh debian/bpftrace/usr/bin/bpftrace-aotrt
 	$(STRIP_CMD) debian/bpftrace/usr/bin/bpftrace
 	$(STRIP_CMD) debian/bpftrace/usr/bin/bpftrace-aotrt
+	dh_strip -Xbpftrace -Xbpftrace-aotrt
 
 override_dh_dwz:
 
-- 
2.48.1

Reply via email to