Mercurial > hg > CbC > CbC_gcc
annotate contrib/compare-debug @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | 855418dad1a3 |
children | f6334be47118 |
rev | line source |
---|---|
0 | 1 #! /bin/sh |
2 | |
3 # Compare stripped copies of two given object files. | |
4 | |
36 | 5 # Copyright (C) 2007, 2008, 2009 Free Software Foundation |
0 | 6 # Originally by Alexandre Oliva <aoliva@redhat.com> |
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 # <http://www.gnu.org/licenses/>. | |
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 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
60 case `uname -s` in |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
61 Darwin) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
62 ld -S -x -r -no_uuid "$1" -o "$1.$suf1" |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
63 ld -S -x -r -no_uuid "$2" -o "$2.$suf2" |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
64 ;; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
65 *) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
66 cp "$1" "$1.$suf1" |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
67 strip "$1.$suf1" |
0 | 68 |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
69 cp "$2" "$2.$suf2" |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
70 strip "$2.$suf2" |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
71 ;; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
72 esac |
0 | 73 |
74 if cmp "$1.$suf1" "$2.$suf2"; then | |
75 status=0 | |
76 else | |
77 status=1 | |
36 | 78 |
79 # Assembler-generated CFI will add an .eh_frame section for -g not | |
80 # present in -g0. Try to cope with it by checking that an .eh_frame | |
81 # section is present in either object file, and then stripping it | |
82 # off before re-comparing. | |
83 | |
84 cmd= | |
85 cmp1= | |
86 cmp2= | |
87 | |
88 for t in objdump readelf eu-readelf; do | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
89 if ($t --help) 2>&1 | grep ' --\[*section-\]*headers' > /dev/null; then |
36 | 90 cmd=$t |
91 | |
92 $cmd --section-headers "$1.$suf1" | grep '\.eh_frame' > /dev/null | |
93 cmp1=$? | |
94 | |
95 $cmd --section-headers "$2.$suf2" | grep '\.eh_frame' > /dev/null | |
96 cmp2=$? | |
97 | |
98 break | |
99 fi | |
100 done | |
101 | |
102 # If we found .eh_frame in one but not the other, or if we could not | |
103 # find a command to tell, try to strip off the .eh_frame section | |
104 # from both. | |
105 if test "x$cmp1" != "x$cmp2" || test "x$cmd" = "x"; then | |
106 suf3=$suf1. | |
107 while test -f "$1.$suf3"; do | |
108 suf3=$suf3. | |
109 done | |
110 | |
111 suf4=$suf2. | |
112 while test -f "$2.$suf4"; do | |
113 suf4=$suf4. | |
114 done | |
115 | |
116 trap 'rm -f "$1.$suf1" "$2.$suf2" "$1.$suf3" "$2.$suf4"' 0 1 2 15 | |
117 | |
118 echo stripping off .eh_frame, then retrying >&2 | |
119 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
120 if (objcopy -v) 2>&1 | grep ' --remove-section' > /dev/null; then |
36 | 121 objcopy --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$1.$suf1" "$1.$suf3" |
122 mv "$1.$suf3" "$1.$suf1" | |
123 | |
124 objcopy --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$2.$suf2" "$2.$suf4" | |
125 mv "$2.$suf4" "$2.$suf2" | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
126 elif (strip --help) 2>&1 | grep ' --remove-section' > /dev/null; then |
36 | 127 cp "$1.$suf1" "$1.$suf3" |
128 strip --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$1.$suf3" | |
129 mv "$1.$suf3" "$1.$suf1" | |
130 | |
131 cp "$2.$suf2" "$2.$suf4" | |
132 strip --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$2.$suf4" | |
133 mv "$2.$suf4" "$2.$suf2" | |
134 else | |
135 echo failed to strip off .eh_frame >&2 | |
136 fi | |
137 | |
138 trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15 | |
139 | |
140 if cmp "$1.$suf1" "$2.$suf2"; then | |
141 status=0 | |
142 else | |
143 status=1 | |
144 fi | |
145 fi | |
0 | 146 fi |
147 | |
148 $rm "$1.$suf1" "$2.$suf2" | |
149 | |
150 trap "exit $status; exit" 0 1 2 15 | |
151 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
152 if test -f "$1".gkd || test -f "$2".gkd; then |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
153 if cmp "$1".gkd "$2".gkd; then |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
154 : |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
155 else |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
156 status=$? |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
157 fi |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
158 fi |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
159 |
0 | 160 exit $status |