michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone
dac7c0
--- rpm-4.11.3/scripts/find-debuginfo.sh.old	2019-01-02 13:14:10.283068553 +0100
dac7c0
+++ rpm-4.11.3/scripts/find-debuginfo.sh	2019-03-21 09:36:06.196400883 +0100
dac7c0
@@ -3,6 +3,7 @@
dac7c0
 #for inclusion in an rpm spec file.
dac7c0
 #
dac7c0
 # Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m]
dac7c0
+#			   [--g-libs]
dac7c0
 #	 		   [-o debugfiles.list]
dac7c0
 #			   [--run-dwz] [--dwz-low-mem-die-limit N]
dac7c0
 #			   [--dwz-max-die-limit N]
dac7c0
@@ -10,6 +11,8 @@
dac7c0
 #			   [builddir]
dac7c0
 #
dac7c0
 # The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
dac7c0
+# The --g-libs flag says to use strip -g instead of full strip ONLY on DSOs.
dac7c0
+# Options -g and --g-libs are mutually exclusive.
dac7c0
 # The --strict-build-id flag says to exit with failure status if
dac7c0
 # any ELF binary processed fails to contain a build-id note.
dac7c0
 # The -r flag says to use eu-strip --reloc-debug-sections.
dac7c0
@@ -32,6 +35,9 @@
dac7c0
 # With -g arg, pass it to strip on libraries or executables.
dac7c0
 strip_g=false
dac7c0
 
dac7c0
+# With --g-libs arg, pass it to strip on libraries.
dac7c0
+strip_glibs=false
dac7c0
+
dac7c0
 # with -r arg, pass --reloc-debug-sections to eu-strip.
dac7c0
 strip_r=false
dac7c0
 
dac7c0
@@ -65,6 +71,9 @@
dac7c0
     dwz_max_die_limit=$2
dac7c0
     shift
dac7c0
     ;;
dac7c0
+  --g-libs)
dac7c0
+    strip_glibs=true
dac7c0
+    ;;
dac7c0
   -g)
dac7c0
     strip_g=true
dac7c0
     ;;
dac7c0
@@ -100,6 +109,11 @@
dac7c0
   shift
dac7c0
 done
dac7c0
 
dac7c0
+if ("$strip_g" = "true") && ("$strip_glibs" = "true"); then
dac7c0
+  echo >&2 "*** ERROR: -g  and --g-libs cannot be used together"
dac7c0
+  exit 2
dac7c0
+fi
dac7c0
+
dac7c0
 i=0
dac7c0
 while ((i < nout)); do
dac7c0
   outs[$i]="$BUILDDIR/${outs[$i]}"
dac7c0
@@ -132,6 +146,9 @@
dac7c0
   application/x-sharedlib*) g=-g ;;
dac7c0
   application/x-executable*) g=-g ;;
dac7c0
   esac
dac7c0
+  $strip_glibs && case "$(file -bi "$2")" in
dac7c0
+    application/x-sharedlib*) g=-g ;;
dac7c0
+  esac
dac7c0
   eu-strip --remove-comment $r $g -f "$1" "$2" || exit
dac7c0
   chmod 444 "$1" || exit
dac7c0
 }
dac7c0
@@ -317,7 +334,23 @@
dac7c0
     chmod u-w "$f"
dac7c0
   fi
dac7c0
 
dac7c0
-  $include_minidebug && add_minidebug "${debugfn}" "$f"
dac7c0
+  # strip -g implies we have full symtab, don't add mini symtab in that case.
dac7c0
+  # It only makes sense to add a minisymtab for executables and shared
dac7c0
+  # libraries. Other executable ELF files (like kernel modules) don't need it.
dac7c0
+  if [ "$include_minidebug" = "true" -a "$strip_g" = "false" ]; then
dac7c0
+    skip_mini=true
dac7c0
+    if [ "$strip_glibs" = "false" ]; then
dac7c0
+      case "$(file -bi "$f")" in
dac7c0
+        application/x-sharedlib*) skip_mini=false ;;
dac7c0
+      esac
dac7c0
+    fi
dac7c0
+    case "$(file -bi "$f")" in
dac7c0
+      application/x-sharedlib*) skip_mini=false ;;
dac7c0
+      application/x-executable*) skip_mini=false ;;
dac7c0
+      application/x-pie-executable*) skip_mini=false ;;
dac7c0
+    esac
dac7c0
+    $skip_mini || add_minidebug "${debugfn}" "$f"
dac7c0
+  fi
dac7c0
 
dac7c0
   echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE"
dac7c0