diff mbox

PATCH: PR bootstrap/53472: contrib/compare-debug should strip out .comment section

Message ID CAMe9rOroNhDgFw6GaUJVRQ5eJKV8Zqd5hAhJFAyZ6KNFjk361Q@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu May 24, 2012, 9:32 p.m. UTC
On Thu, May 24, 2012 at 9:53 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, May 24, 2012 at 7:43 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Thu, May 24, 2012 at 7:35 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
>>> Il 24/05/2012 16:01, H.J. Lu ha scritto:
>>>> configure checks if contrib/compare-debug actually works for comparing a
>>>> debug and non-debug .o file before enabling bootstrap-debug.  But some
>>>> compilers encode some command line options (among them -g) into a special
>>>> .comment section.  This patch removes .comment section before comparing
>>>> debug and non-debug files.  OK for trunk?
>>>
>>> Ok.
>>
>> Hi Richard,
>>
>> Before I check it in,  can you verify it enables bootstrap-debug on SuSE?
>>
>
> It doesn't work since the comment section name may be
> .comment.SUSE.OPTs
>

This patch works on openSUSE 12.1.  OK to install?

Thanks.

Comments

Jakub Jelinek May 24, 2012, 9:43 p.m. UTC | #1
On Thu, May 24, 2012 at 02:32:59PM -0700, H.J. Lu wrote:
> This patch works on openSUSE 12.1.  OK to install?

Can't you do that only if the first cmp failed?
In that case strip and cmp again...

> 2012-05-24  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	PR bootstrap/53472
> 	* contrib/compare-debug (remove_comment): New function.
> 	Also remove any .comment sections.
> 
> diff --git a/contrib/compare-debug b/contrib/compare-debug
> index 010d17f..2468899 100755
> --- a/contrib/compare-debug
> +++ b/contrib/compare-debug
> @@ -73,6 +73,27 @@ Darwin)
>    ;;
>  esac
> 
> +remove_comment ()
> +{
> +  file=$1
> +  opts=
> +  for s in `objdump --section-headers "$file" | awk '{ print $2 }'`; do
> +    case "$s" in
> +    .comment*)
> +      opts="$opts --remove-section $s"
> +      ;;
> +    esac
> +  done
> +  [ -n "$opts" ] && objcopy $opts $file
> +}
> +
> +# Also remove any .comment sections.
> +if (objcopy -v) 2>&1 | grep ' --remove-section' > /dev/null \
> +   && (objdump --help) 2>&1 | grep ' --\[*section-\]*headers' > /dev/null; then
> +  remove_comment "$1.$suf1"
> +  remove_comment "$2.$suf2"
> +fi
> +
>  if cmp "$1.$suf1" "$2.$suf2"; then
>    status=0
>  else

	Jakub
diff mbox

Patch

diff --git a/contrib/compare-debug b/contrib/compare-debug
index 010d17f..2468899 100755
--- a/contrib/compare-debug
+++ b/contrib/compare-debug
@@ -73,6 +73,27 @@  Darwin)
   ;;
 esac

+remove_comment ()
+{
+  file=$1
+  opts=
+  for s in `objdump --section-headers "$file" | awk '{ print $2 }'`; do
+    case "$s" in
+    .comment*)
+      opts="$opts --remove-section $s"
+      ;;
+    esac
+  done
+  [ -n "$opts" ] && objcopy $opts $file
+}
+
+# Also remove any .comment sections.
+if (objcopy -v) 2>&1 | grep ' --remove-section' > /dev/null \
+   && (objdump --help) 2>&1 | grep ' --\[*section-\]*headers' > /dev/null; then
+  remove_comment "$1.$suf1"
+  remove_comment "$2.$suf2"
+fi
+
 if cmp "$1.$suf1" "$2.$suf2"; then
   status=0
 else