OSDN Git Service

ChangeLog:
[pf3gnuchains/gcc-fork.git] / contrib / compare-debug
1 #! /bin/sh
2
3 # Compare stripped copies of two given object files.
4
5 # Copyright (C) 2007 Free Software Foundation
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 if test $# != 2; then
25   echo 'usage: compare-debug file1.o file2.o' >&2
26   exit 1
27 fi
28
29 if test ! -f "$1"; then
30   echo "$1" does not exist >&2
31   exit 1
32 fi
33
34 if test ! -f "$2"; then
35   echo "$2" does not exist >&2
36   exit 1
37 fi
38
39 if test -f "$1".stripped; then
40   echo "$1".stripped already exists, overwriting >&2
41   exit 1
42 fi
43
44 if test -f "$2".stripped; then
45   echo "$2".stripped already exists, overwriting >&2
46   exit 1
47 fi
48
49 trap 'rm -f "$1".stripped "$2".stripped' 0 1 2 15
50
51 cp "$1" "$1".stripped
52 strip "$1".stripped
53
54 cp "$2" "$2".stripped
55 strip "$2".stripped
56
57 if cmp "$1".stripped "$2".stripped; then
58   status=0
59 else
60   status=1
61 fi
62
63 rm -f "$1".stripped "$2".stripped
64
65 trap "exit $status; exit" 0 1 2 15
66
67 exit $status