diff mbox

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

Message ID CAMe9rOp5HYpPuM+7573ZE7QF1yC-4n=YFDHgJj8ntr-4q+Wsww@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu May 24, 2012, 10:03 p.m. UTC
On Thu, May 24, 2012 at 2:43 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> 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...
>

Like this?  OK to install?

Thanks.

Comments

Paolo Bonzini May 25, 2012, 6:30 a.m. UTC | #1
> 2012-05-24  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR bootstrap/53472
>        * contrib/compare-debug (remove_comment): New function.
>        Remove any .comment sections if the first cmp failed.

Ok.

Paolo

> diff --git a/contrib/compare-debug b/contrib/compare-debug
> index 010d17f..fb8986d 100755
> --- a/contrib/compare-debug
> +++ b/contrib/compare-debug
> @@ -73,11 +73,35 @@ 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
> +}
> +
>  if cmp "$1.$suf1" "$2.$suf2"; then
>   status=0
>  else
>   status=1
>
> +  # 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"
> +    if cmp "$1.$suf1" "$2.$suf2"; then
> +      status=0
> +    fi
> +  fi
> +
>   # Assembler-generated CFI will add an .eh_frame section for -g not
>   # present in -g0.  Try to cope with it by checking that an .eh_frame
>   # section is present in either object file, and then stripping it
>
diff mbox

Patch

diff --git a/contrib/compare-debug b/contrib/compare-debug
index 010d17f..fb8986d 100755
--- a/contrib/compare-debug
+++ b/contrib/compare-debug
@@ -73,11 +73,35 @@  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
+}
+
 if cmp "$1.$suf1" "$2.$suf2"; then
   status=0
 else
   status=1

+  # 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"
+    if cmp "$1.$suf1" "$2.$suf2"; then
+      status=0
+    fi
+  fi
+
   # Assembler-generated CFI will add an .eh_frame section for -g not
   # present in -g0.  Try to cope with it by checking that an .eh_frame