OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [contrib/] [compare-debug] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 265 jeremybenn
#! /bin/sh
2
 
3
# Compare stripped copies of two given object files.
4
 
5
# Copyright (C) 2007, 2008, 2009 Free Software Foundation
6
# Originally by Alexandre Oliva 
7
 
8
# This file is part of GCC.
9
 
10
# GCC is free software; you can redistribute it and/or modify it under
11
# the terms of the GNU General Public License as published by the Free
12
# Software Foundation; either version 3, or (at your option) any later
13
# version.
14
 
15
# GCC is distributed in the hope that it will be useful, but WITHOUT
16
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
18
# License for more details.
19
 
20
# You should have received a copy of the GNU General Public License
21
# along with GCC; see the file COPYING3.  If not see
22
# .
23
 
24
rm='rm -f'
25
 
26
case $1 in
27
-p | --preserve)
28
  rm='echo preserving'
29
  shift
30
  ;;
31
esac
32
 
33
if test $# != 2; then
34
  echo 'usage: compare-debug file1.o file2.o' >&2
35
  exit 1
36
fi
37
 
38
if test ! -f "$1"; then
39
  echo "$1" does not exist >&2
40
  exit 1
41
fi
42
 
43
if test ! -f "$2"; then
44
  echo "$2" does not exist >&2
45
  exit 1
46
fi
47
 
48
suf1=stripped
49
while test -f "$1.$suf1"; do
50
  suf1=$suf1.
51
done
52
 
53
suf2=stripped
54
while test -f "$2.$suf2"; do
55
  suf2=$suf2.
56
done
57
 
58
trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15
59
 
60
case `uname -s` in
61
Darwin)
62
  # The strip command on darwin does not remove all debug info.
63
  # Fortunately, we can use ld to do it instead.
64
  ld -S -r -no_uuid "$1" -o "$1.$suf1"
65
  ld -S -r -no_uuid "$2" -o "$2.$suf2"
66
  ;;
67
*)
68
  cp "$1" "$1.$suf1"
69
  strip "$1.$suf1"
70
 
71
  cp "$2" "$2.$suf2"
72
  strip "$2.$suf2"
73
  ;;
74
esac
75
 
76
if cmp "$1.$suf1" "$2.$suf2"; then
77
  status=0
78
else
79
  status=1
80
 
81
  # Assembler-generated CFI will add an .eh_frame section for -g not
82
  # present in -g0.  Try to cope with it by checking that an .eh_frame
83
  # section is present in either object file, and then stripping it
84
  # off before re-comparing.
85
 
86
  cmd=
87
  cmp1=
88
  cmp2=
89
 
90
  for t in objdump readelf eu-readelf; do
91
    if ($t --help) 2>&1 | grep ' --\[*section-\]*headers' > /dev/null; then
92
      cmd=$t
93
 
94
      $cmd --section-headers "$1.$suf1" | grep '\.eh_frame' > /dev/null
95
      cmp1=$?
96
 
97
      $cmd --section-headers "$2.$suf2" | grep '\.eh_frame' > /dev/null
98
      cmp2=$?
99
 
100
      break
101
    fi
102
  done
103
 
104
  # If we found .eh_frame in one but not the other, or if we could not
105
  # find a command to tell, try to strip off the .eh_frame section
106
  # from both.
107
  if test "x$cmp1" != "x$cmp2" || test "x$cmd" = "x"; then
108
    suf3=$suf1.
109
    while test -f "$1.$suf3"; do
110
      suf3=$suf3.
111
    done
112
 
113
    suf4=$suf2.
114
    while test -f "$2.$suf4"; do
115
      suf4=$suf4.
116
    done
117
 
118
    trap 'rm -f "$1.$suf1" "$2.$suf2" "$1.$suf3" "$2.$suf4"' 0 1 2 15
119
 
120
    echo stripping off .eh_frame, then retrying >&2
121
 
122
    if (objcopy -v) 2>&1 | grep ' --remove-section' > /dev/null; then
123
      objcopy --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$1.$suf1" "$1.$suf3"
124
      mv "$1.$suf3" "$1.$suf1"
125
 
126
      objcopy --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$2.$suf2" "$2.$suf4"
127
      mv "$2.$suf4" "$2.$suf2"
128
    elif (strip --help) 2>&1 | grep ' --remove-section' > /dev/null; then
129
      cp "$1.$suf1" "$1.$suf3"
130
      strip --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$1.$suf3"
131
      mv "$1.$suf3" "$1.$suf1"
132
 
133
      cp "$2.$suf2" "$2.$suf4"
134
      strip --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$2.$suf4"
135
      mv "$2.$suf4" "$2.$suf2"
136
    else
137
      echo failed to strip off .eh_frame >&2
138
    fi
139
 
140
    trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15
141
 
142
    if cmp "$1.$suf1" "$2.$suf2"; then
143
      status=0
144
    else
145
      status=1
146
    fi
147
  fi
148
fi
149
 
150
$rm "$1.$suf1" "$2.$suf2"
151
 
152
trap "exit $status; exit" 0 1 2 15
153
 
154
if test -f "$1".gkd || test -f "$2".gkd; then
155
  if cmp "$1".gkd "$2".gkd; then
156
    :
157
  else
158
    status=$?
159
  fi
160
fi
161
 
162
exit $status

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.