dcavalca / rpms / rpm

Forked from rpms/rpm a year ago
Clone

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

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