teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame 0023-minisymtab-exe-sh.patch

Mark Wielaard e589ca
commit 95822abd90b9b3991b15ba82193abb5b9998dc99
Mark Wielaard e589ca
Author: Mark Wielaard <mark@klomp.org>
Mark Wielaard e589ca
Date:   Sat Apr 15 13:34:18 2017 +0200
Mark Wielaard e589ca
Mark Wielaard e589ca
    find-debuginfo.sh: Only add minisymtab for executables or shared libraries.
Mark Wielaard e589ca
    
Mark Wielaard e589ca
    It only makes sense to add a minisymtab for executables and shared
Mark Wielaard e589ca
    libraries. Other executable ELF files (like kernel modules) don't need it.
Mark Wielaard e589ca
    Since those don't have a dynsym section trying to add it will fail and
Mark Wielaard e589ca
    produce confusing errors from nm.
Mark Wielaard e589ca
    
Mark Wielaard e589ca
    Signed-off-by: Mark Wielaard <mark@klomp.org>
Mark Wielaard e589ca
Mark Wielaard e589ca
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
Mark Wielaard e589ca
index 6f38e19..39bb0b7 100755
Mark Wielaard e589ca
--- a/scripts/find-debuginfo.sh
Mark Wielaard e589ca
+++ b/scripts/find-debuginfo.sh
Mark Wielaard e589ca
@@ -358,7 +358,16 @@ do_file()
Mark Wielaard e589ca
   fi
Mark Wielaard e589ca
 
Mark Wielaard e589ca
   # strip -g implies we have full symtab, don't add mini symtab in that case.
Mark Wielaard e589ca
-  $strip_g || ($include_minidebug && add_minidebug "${debugfn}" "$f")
Mark Wielaard e589ca
+  # It only makes sense to add a minisymtab for executables and shared
Mark Wielaard e589ca
+  # libraries. Other executable ELF files (like kernel modules) don't need it.
Mark Wielaard e589ca
+  if [ "$include_minidebug" = "true" -a "$strip_g" = "false" ]; then
Mark Wielaard e589ca
+    skip_mini=true
Mark Wielaard e589ca
+    case "$(file -bi "$f")" in
Mark Wielaard e589ca
+      application/x-sharedlib*) skip_mini=false ;;
Mark Wielaard e589ca
+      application/x-executable*) skip_mini=false ;;
Mark Wielaard e589ca
+    esac
Mark Wielaard e589ca
+    $skip_mini || add_minidebug "${debugfn}" "$f"
Mark Wielaard e589ca
+  fi
Mark Wielaard e589ca
 
Mark Wielaard e589ca
   echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE"
Mark Wielaard e589ca