Blob Blame History Raw
commit 95822abd90b9b3991b15ba82193abb5b9998dc99
Author: Mark Wielaard <mark@klomp.org>
Date:   Sat Apr 15 13:34:18 2017 +0200

    find-debuginfo.sh: Only add minisymtab for executables or shared libraries.
    
    It only makes sense to add a minisymtab for executables and shared
    libraries. Other executable ELF files (like kernel modules) don't need it.
    Since those don't have a dynsym section trying to add it will fail and
    produce confusing errors from nm.
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>

diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 6f38e19..39bb0b7 100755
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -358,7 +358,16 @@ do_file()
   fi
 
   # strip -g implies we have full symtab, don't add mini symtab in that case.
-  $strip_g || ($include_minidebug && add_minidebug "${debugfn}" "$f")
+  # It only makes sense to add a minisymtab for executables and shared
+  # libraries. Other executable ELF files (like kernel modules) don't need it.
+  if [ "$include_minidebug" = "true" -a "$strip_g" = "false" ]; then
+    skip_mini=true
+    case "$(file -bi "$f")" in
+      application/x-sharedlib*) skip_mini=false ;;
+      application/x-executable*) skip_mini=false ;;
+    esac
+    $skip_mini || add_minidebug "${debugfn}" "$f"
+  fi
 
   echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE"