teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame 0001-Add-flag-to-use-strip-g-instead-of-full-strip-on-DSO.patch

Panu Matilainen 57b4e9
From 1da9e839bb573b9187403983f5a69853ab364306 Mon Sep 17 00:00:00 2001
Panu Matilainen 57b4e9
Message-Id: <1da9e839bb573b9187403983f5a69853ab364306.1554879119.git.pmatilai@redhat.com>
Panu Matilainen 57b4e9
From: Pavlina Moravcova Varekova <pmoravco@redhat.com>
Panu Matilainen 57b4e9
Date: Sun, 17 Mar 2019 06:47:26 +0100
Panu Matilainen 57b4e9
Subject: [PATCH] Add flag to use strip -g instead of full strip on DSOs
Panu Matilainen 57b4e9
 (RhBug:1663264)
Panu Matilainen 57b4e9
Panu Matilainen 57b4e9
The find-debuginfo.sh flag -g had exactly this meaning. But from
Panu Matilainen 57b4e9
version rpm-4.13.0-alpha flag -g changes its behavior. It affects
Panu Matilainen 57b4e9
both libraries and executables.
Panu Matilainen 57b4e9
Panu Matilainen 57b4e9
For some packages the original behavior was preferred. That is why
Panu Matilainen 57b4e9
the new find-debuginfo.sh flag --g-libs is created.
Panu Matilainen 57b4e9
Panu Matilainen 57b4e9
Options -g and --g-libs are mutually exclusive.
Panu Matilainen 57b4e9
---
Panu Matilainen 57b4e9
 scripts/find-debuginfo.sh | 23 ++++++++++++++++++++++-
Panu Matilainen 57b4e9
 1 file changed, 22 insertions(+), 1 deletion(-)
Panu Matilainen 57b4e9
Panu Matilainen 57b4e9
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
Panu Matilainen 57b4e9
index 6e3ba2ce0..c75d176ac 100755
Panu Matilainen 57b4e9
--- a/scripts/find-debuginfo.sh
Panu Matilainen 57b4e9
+++ b/scripts/find-debuginfo.sh
Panu Matilainen 57b4e9
@@ -4,6 +4,7 @@
Panu Matilainen 57b4e9
 #
Panu Matilainen 57b4e9
 # Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
Panu Matilainen 57b4e9
 #			   [--keep-section SECTION] [--remove-section SECTION]
Panu Matilainen 57b4e9
+#			   [--g-libs]
Panu Matilainen 57b4e9
 #	 		   [-j N] [--jobs N]
Panu Matilainen 57b4e9
 #	 		   [-o debugfiles.list]
Panu Matilainen 57b4e9
 #	 		   [-S debugsourcefiles.list]
Panu Matilainen 57b4e9
@@ -16,6 +17,8 @@
Panu Matilainen 57b4e9
 #			   [builddir]
Panu Matilainen 57b4e9
 #
Panu Matilainen 57b4e9
 # The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
Panu Matilainen 57b4e9
+# The --g-libs flag says to use strip -g instead of full strip ONLY on DSOs.
Panu Matilainen 57b4e9
+# Options -g and --g-libs are mutually exclusive.
Panu Matilainen 57b4e9
 # The -r flag says to use eu-strip --reloc-debug-sections.
Panu Matilainen 57b4e9
 # Use --keep-section SECTION or --remove-section SECTION to explicitly
Panu Matilainen 57b4e9
 # keep a (non-allocated) section in the main executable or explicitly
Panu Matilainen 57b4e9
@@ -68,6 +71,9 @@ lib_rpm_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Panu Matilainen 57b4e9
 # With -g arg, pass it to strip on libraries or executables.
Panu Matilainen 57b4e9
 strip_g=false
Panu Matilainen 57b4e9
 
Panu Matilainen 57b4e9
+# With --g-libs arg, pass it to strip on libraries.
Panu Matilainen 57b4e9
+strip_glibs=false
Panu Matilainen 57b4e9
+
Panu Matilainen 57b4e9
 # with -r arg, pass --reloc-debug-sections to eu-strip.
Panu Matilainen 57b4e9
 strip_r=false
Panu Matilainen 57b4e9
 
Panu Matilainen 57b4e9
@@ -135,6 +141,9 @@ while [ $# -gt 0 ]; do
Panu Matilainen 57b4e9
     unique_debug_src_base=$2
Panu Matilainen 57b4e9
     shift
Panu Matilainen 57b4e9
     ;;
Panu Matilainen 57b4e9
+  --g-libs)
Panu Matilainen 57b4e9
+    strip_glibs=true
Panu Matilainen 57b4e9
+    ;;
Panu Matilainen 57b4e9
   -g)
Panu Matilainen 57b4e9
     strip_g=true
Panu Matilainen 57b4e9
     ;;
Panu Matilainen 57b4e9
@@ -204,6 +213,11 @@ if test -n "$build_id_seed" -a "$no_recompute_build_id" = "true"; then
Panu Matilainen 57b4e9
   exit 2
Panu Matilainen 57b4e9
 fi
Panu Matilainen 57b4e9
 
Panu Matilainen 57b4e9
+if ("$strip_g" = "true") && ("$strip_glibs" = "true"); then
Panu Matilainen 57b4e9
+  echo >&2 "*** ERROR: -g  and --g-libs cannot be used together"
Panu Matilainen 57b4e9
+  exit 2
Panu Matilainen 57b4e9
+fi
Panu Matilainen 57b4e9
+
Panu Matilainen 57b4e9
 i=0
Panu Matilainen 57b4e9
 while ((i < nout)); do
Panu Matilainen 57b4e9
   outs[$i]="$BUILDDIR/${outs[$i]}"
Panu Matilainen 57b4e9
@@ -237,6 +251,9 @@ strip_to_debug()
Panu Matilainen 57b4e9
   application/x-executable*) g=-g ;;
Panu Matilainen 57b4e9
   application/x-pie-executable*) g=-g ;;
Panu Matilainen 57b4e9
   esac
Panu Matilainen 57b4e9
+  $strip_glibs && case "$(file -bi "$2")" in
Panu Matilainen 57b4e9
+    application/x-sharedlib*) g=-g ;;
Panu Matilainen 57b4e9
+  esac
Panu Matilainen 57b4e9
   eu-strip --remove-comment $r $g ${keep_remove_args} -f "$1" "$2" || exit
Panu Matilainen 57b4e9
   chmod 444 "$1" || exit
Panu Matilainen 57b4e9
 }
Panu Matilainen 57b4e9
@@ -409,8 +426,12 @@ do_file()
Panu Matilainen 57b4e9
   # libraries. Other executable ELF files (like kernel modules) don't need it.
Panu Matilainen 57b4e9
   if [ "$include_minidebug" = "true" -a "$strip_g" = "false" ]; then
Panu Matilainen 57b4e9
     skip_mini=true
Panu Matilainen 57b4e9
+    if [ "$strip_glibs" = "false" ]; then
Panu Matilainen 57b4e9
+      case "$(file -bi "$f")" in
Panu Matilainen 57b4e9
+        application/x-sharedlib*) skip_mini=false ;;
Panu Matilainen 57b4e9
+      esac
Panu Matilainen 57b4e9
+    fi
Panu Matilainen 57b4e9
     case "$(file -bi "$f")" in
Panu Matilainen 57b4e9
-      application/x-sharedlib*) skip_mini=false ;;
Panu Matilainen 57b4e9
       application/x-executable*) skip_mini=false ;;
Panu Matilainen 57b4e9
       application/x-pie-executable*) skip_mini=false ;;
Panu Matilainen 57b4e9
     esac
Panu Matilainen 57b4e9
-- 
Panu Matilainen 57b4e9
2.20.1
Panu Matilainen 57b4e9