[rpm] - add support for minidebuginfo generation (#834073)
Panu Matilainen
pmatilai at fedoraproject.org
Wed Jun 27 10:29:04 UTC 2012
commit 7f2e4e1cba32712fe0608d5ce4c7e156d095e14a
Author: Panu Matilainen <pmatilai at redhat.com>
Date: Wed Jun 27 13:17:26 2012 +0300
- add support for minidebuginfo generation (#834073)
rpm-4.10.0-minidebuginfo.patch | 98 ++++++++++++++++++++++++++++++++++++++++
rpm.spec | 8 +++-
2 files changed, 105 insertions(+), 1 deletions(-)
---
diff --git a/rpm-4.10.0-minidebuginfo.patch b/rpm-4.10.0-minidebuginfo.patch
new file mode 100644
index 0000000..54c0e32
--- /dev/null
+++ b/rpm-4.10.0-minidebuginfo.patch
@@ -0,0 +1,98 @@
+--- rpm-4.10.0/macros.in 2012-06-11 11:16:21.216952339 +0200
++++ rpm-4.10.0/macros.in.minidebug 2012-06-11 11:16:23.686912455 +0200
+@@ -175,7 +175,7 @@
+ # the script. See the script for details.
+ #
+ %__debug_install_post \
+- %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
++ %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_include_minidebuginfo:-m} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
+ %{nil}
+
+ # Template for debug information sub-package.
+@@ -418,6 +418,12 @@ package or when debugging this package.\
+ #%_missing_build_ids_terminate_build 1
+
+ #
++# Include minimal debug information in build binaries.
++# Requires _enable_debug_packages.
++#
++#%_include_minidebuginfo 1
++
++#
+ # Use internal dependency generator rather than external helpers?
+ %_use_internal_dependency_generator 1
+
+--- rpm-4.10.0/scripts/find-debuginfo.sh 2012-06-11 11:16:09.698138273 +0200
++++ rpm-4.10.0/scripts/find-debuginfo.sh.minidebug 2012-06-11 11:16:13.399078526 +0200
+@@ -2,7 +2,7 @@
+ #find-debuginfo.sh - automagically generate debug info and file list
+ #for inclusion in an rpm spec file.
+ #
+-# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r]
++# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m]
+ # [-o debugfiles.list]
+ # [--run-dwz] [--dwz-low-mem-die-limit N]
+ # [--dwz-max-die-limit N]
+@@ -29,6 +29,9 @@ strip_g=false
+ # with -r arg, pass --reloc-debug-sections to eu-strip.
+ strip_r=false
+
++# with -m arg, add minimal debuginfo to binary.
++include_minidebug=false
++
+ # Barf on missing build IDs.
+ strict=false
+
+@@ -43,6 +46,9 @@ while [ $# -gt 0 ]; do
+ -g)
+ strip_g=true
+ ;;
++ -m)
++ include_minidebug=true
++ ;;
+ -o)
+ if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then
+ out=$2
+@@ -105,6 +111,32 @@ strip_to_debug()
+ chmod 444 "$1" || exit
+ }
+
++add_minidebug()
++{
++ local debuginfo="$1"
++ local binary="$2"
++
++ local dynsyms=`mktemp`
++ local funcsyms=`mktemp`
++ local keep_symbols=`mktemp`
++ local mini_debuginfo=`mktemp`
++
++ # Extract the dynamic symbols from the main binary, there is no need to also have these
++ # in the normal symbol table
++ nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms"
++ # Extract all the text (i.e. function) symbols from the debuginfo
++ nm "$debuginfo" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > "$funcsyms"
++ # Keep all the function symbols not already in the dynamic symbol table
++ comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols"
++ # Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections
++ objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null
++ #Inject the compressed data into the .gnu_debugdata section of the original binary
++ xz "$mini_debuginfo"
++ mini_debuginfo="${mini_debuginfo}.xz"
++ objcopy --add-section .gnu_debugdata="$mini_debuginfo" "$binary"
++ rm -f "$dynsyms" "$funcsyms" "$keep_symbols" "$mini_debuginfo"
++}
++
+ # Make a relative symlink to $1 called $3$2
+ shopt -s extglob
+ link_relative()
+@@ -260,6 +292,9 @@ while read nlinks inum f; do
+ chmod u-w "$f"
+ fi
+
++ $include_minidebug && add_minidebug "${debugfn}" "$f"
++
++
+ if [ -n "$id" ]; then
+ make_id_link "$id" "$dn/$(basename $f)"
+ make_id_link "$id" "/usr/lib/debug$dn/$bn" .debug
diff --git a/rpm.spec b/rpm.spec
index 45632d4..ed439db 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -21,7 +21,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
-Release: %{?snapver:0.%{snapver}.}2%{?dist}
+Release: %{?snapver:0.%{snapver}.}3%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/rpm-4.10.x/%{name}-%{srcver}.tar.bz2
@@ -53,6 +53,8 @@ Patch302: rpm-4.7.1-geode-i686.patch
Patch304: rpm-4.9.1.1-ld-flags.patch
# Compressed debuginfo support (#833311)
Patch305: rpm-4.10.0-dwz-debuginfo.patch
+# Minidebuginfo support (#834073)
+Patch306: rpm-4.10.0-minidebuginfo.patch
# Temporary Patch to provide support for updates
Patch400: rpm-4.9.1.2-rpmlib-filesystem-check.patch
@@ -220,6 +222,7 @@ packages on a system.
%patch302 -p1 -b .geode
%patch304 -p1 -b .ldflags
%patch305 -p1 -b .dwz-debuginfo
+%patch306 -p1 -b .minidebuginfo
%patch400 -p1 -b .rpmlib-filesystem-check
@@ -442,6 +445,9 @@ exit 0
%doc COPYING doc/librpm/html/*
%changelog
+* Wed Jun 27 2012 Panu Matilainen <pmatilai at redhat.com> - 4.10.0-3
+- add support for minidebuginfo generation (#834073)
+
* Mon Jun 25 2012 Panu Matilainen <pmatilai at redhat.com> - 4.10.0-2
- add dwarf compression support to debuginfo generation (#833311)
More information about the scm-commits
mailing list