Mercurial > hg > CbC > CbC_gcc
comparison contrib/compare-debug @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | 77e2b8dfacca |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 #! /bin/sh | 1 #! /bin/sh |
2 | 2 |
3 # Compare stripped copies of two given object files. | 3 # Compare stripped copies of two given object files. |
4 | 4 |
5 # Copyright (C) 2007, 2008, 2009 Free Software Foundation | 5 # Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation |
6 # Originally by Alexandre Oliva <aoliva@redhat.com> | 6 # Originally by Alexandre Oliva <aoliva@redhat.com> |
7 | 7 |
8 # This file is part of GCC. | 8 # This file is part of GCC. |
9 | 9 |
10 # GCC is free software; you can redistribute it and/or modify it under | 10 # GCC is free software; you can redistribute it and/or modify it under |
57 | 57 |
58 trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15 | 58 trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15 |
59 | 59 |
60 case `uname -s` in | 60 case `uname -s` in |
61 Darwin) | 61 Darwin) |
62 ld -S -x -r -no_uuid "$1" -o "$1.$suf1" | 62 # The strip command on darwin does not remove all debug info. |
63 ld -S -x -r -no_uuid "$2" -o "$2.$suf2" | 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" | |
64 ;; | 66 ;; |
65 *) | 67 *) |
66 cp "$1" "$1.$suf1" | 68 cp "$1" "$1.$suf1" |
67 strip "$1.$suf1" | 69 strip "$1.$suf1" |
68 | 70 |
98 break | 100 break |
99 fi | 101 fi |
100 done | 102 done |
101 | 103 |
102 # If we found .eh_frame in one but not the other, or if we could not | 104 # 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 | 105 # find a command to tell, or if there are LTO sections, try to strip |
104 # from both. | 106 # off the .eh_frame and LTO sections from both. |
105 if test "x$cmp1" != "x$cmp2" || test "x$cmd" = "x"; then | 107 if test "x$cmp1" != "x$cmp2" || test "x$cmd" = "x" || |
108 $cmd --section-headers "$1.$suf1" | grep '.gnu.lto_' > /dev/null || | |
109 $cmd --section-headers "$2.$suf2" | grep '.gnu.lto_' > /dev/null ; then | |
106 suf3=$suf1. | 110 suf3=$suf1. |
107 while test -f "$1.$suf3"; do | 111 while test -f "$1.$suf3"; do |
108 suf3=$suf3. | 112 suf3=$suf3. |
109 done | 113 done |
110 | 114 |
113 suf4=$suf4. | 117 suf4=$suf4. |
114 done | 118 done |
115 | 119 |
116 trap 'rm -f "$1.$suf1" "$2.$suf2" "$1.$suf3" "$2.$suf4"' 0 1 2 15 | 120 trap 'rm -f "$1.$suf1" "$2.$suf2" "$1.$suf3" "$2.$suf4"' 0 1 2 15 |
117 | 121 |
118 echo stripping off .eh_frame, then retrying >&2 | 122 echo stripping off .eh_frame and LTO sections, then retrying >&2 |
123 | |
124 seclist=".eh_frame .rel.eh_frame .rela.eh_frame" | |
125 if test "x$cmd" != "x"; then | |
126 seclist="$seclist "`{ $cmd --section-headers "$1.$suf1"; $cmd --section-headers "$2.$suf2"; } | sed -n 's,.* \(\.gnu\.lto_[^ ]*\).*,\1,p' | sort -u` | |
127 fi | |
128 rsopts=`for sec in $seclist; do echo " --remove-section $sec"; done` | |
119 | 129 |
120 if (objcopy -v) 2>&1 | grep ' --remove-section' > /dev/null; then | 130 if (objcopy -v) 2>&1 | grep ' --remove-section' > /dev/null; then |
121 objcopy --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$1.$suf1" "$1.$suf3" | 131 objcopy $rsopts "$1.$suf1" "$1.$suf3" |
122 mv "$1.$suf3" "$1.$suf1" | 132 mv "$1.$suf3" "$1.$suf1" |
123 | 133 |
124 objcopy --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$2.$suf2" "$2.$suf4" | 134 objcopy $rsopts "$2.$suf2" "$2.$suf4" |
125 mv "$2.$suf4" "$2.$suf2" | 135 mv "$2.$suf4" "$2.$suf2" |
126 elif (strip --help) 2>&1 | grep ' --remove-section' > /dev/null; then | 136 elif (strip --help) 2>&1 | grep ' --remove-section' > /dev/null; then |
127 cp "$1.$suf1" "$1.$suf3" | 137 cp "$1.$suf1" "$1.$suf3" |
128 strip --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$1.$suf3" | 138 strip $rsopts "$1.$suf3" |
129 mv "$1.$suf3" "$1.$suf1" | 139 mv "$1.$suf3" "$1.$suf1" |
130 | 140 |
131 cp "$2.$suf2" "$2.$suf4" | 141 cp "$2.$suf2" "$2.$suf4" |
132 strip --remove-section .eh_frame --remove-section .rel.eh_frame --remove-section .rela.eh_frame "$2.$suf4" | 142 strip $rsopts "$2.$suf4" |
133 mv "$2.$suf4" "$2.$suf2" | 143 mv "$2.$suf4" "$2.$suf2" |
134 else | 144 else |
135 echo failed to strip off .eh_frame >&2 | 145 echo failed to strip off .eh_frame >&2 |
136 fi | 146 fi |
137 | 147 |