File oprofile-compressed-kernel.patch of Package oprofile

From: Tony Jones
Subject: all compressed kernel when determining range
Upstream: no

Extracted from 0.9.7 patch 'oprofile-0.9.5-buildfixes.diff'.

This needs further investigation as purpose is unclear, since compressed image
isn't supported by underlying sampling code.

--- a/utils/opcontrol
+++ b/utils/opcontrol
@@ -482,10 +482,19 @@ get_image_range()
 		exit 1
 	fi
 
+	kernel_file=$FILE_IMAGE
+	case $(file -L $kernel_file) in
+	  *"gzip compressed"*)
+	    kernel_file=$(mktemp /tmp/opcXXXXXX) || exit 1
+	    trap "rm -f $kernel_file" EXIT
+	    gzip -cd $FILE_IMAGE > $kernel_file
+	    ;;
+	esac
+
 	# start at the start of .text, and end at _etext
-	range_info=`objdump -h $FILE_IMAGE 2>/dev/null | grep " .text "`
+	range_info=`objdump -h $kernel_file 2>/dev/null | grep " .text "`
 	tmp1=`echo $range_info | awk '{print $4}'`
-	tmp2=`objdump -t $FILE_IMAGE 2>/dev/null | grep "_etext$" | awk '{ print $1 }'`
+	tmp2=`objdump -t $kernel_file 2>/dev/null | grep "_etext$" | awk '{ print $1 }'`
 
 	if test -z "$tmp1" -o -z "$tmp2"; then
 		echo "The specified file $FILE_IMAGE does not seem to be valid" >&2
openSUSE Build Service is sponsored by