OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 # | 6 # |
7 # Helper script to run dump_syms on Chrome Linux executables and "fixup" the | 7 # Helper script to run dump_syms on Chrome Linux executables and "fixup" the |
8 # generated sigs (due to changes to the binary from stripping). | 8 # generated sigs (due to changes to the binary from stripping). |
9 | 9 |
10 set -e | 10 set -e |
11 | 11 |
12 usage() { | 12 usage() { |
13 echo "$0 <dump_syms_exe> <binary_with_symbols> <symbols_output>" >&2 | 13 echo -n "$0 <dump_syms_exe> <strip_binary> " >&2 |
| 14 echo "<binary_with_symbols> <symbols_output>" >&2 |
14 } | 15 } |
15 | 16 |
16 | 17 |
17 if [ $# -ne 3 ]; then | 18 if [ $# -ne 4 ]; then |
18 usage | 19 usage |
19 exit 1 | 20 exit 1 |
20 fi | 21 fi |
21 | 22 |
22 SCRIPTDIR="$(readlink -f "$(dirname "$0")")" | 23 SCRIPTDIR="$(readlink -f "$(dirname "$0")")" |
23 DUMPSYMS="$1" | 24 DUMPSYMS="$1" |
24 INFILE="$2" | 25 KEEP_STRIPPED_BINARY="$2" |
25 OUTFILE="$3" | 26 INFILE="$3" |
| 27 OUTFILE="$4" |
26 | 28 |
27 STRIPPED=$(mktemp -q -t stripped-XXXXX) | 29 STRIPPED=$(mktemp -q -t stripped-XXXXX) |
28 if [ $? -ne 0 ]; then | 30 if [ $? -ne 0 ]; then |
29 echo "ERROR: Could not create temp stripped '$INFILE'" >&2 | 31 echo "ERROR: Could not create temp stripped '$INFILE'" >&2 |
30 exit 1 | 32 exit 1 |
31 fi | 33 fi |
32 | 34 |
33 # Dump the symbols from the given binary. | 35 # Dump the symbols from the given binary. |
34 if [ ! -e "$OUTFILE" -o "$INFILE" -nt "$OUTFILE" ]; then | 36 if [ ! -e "$OUTFILE" -o "$INFILE" -nt "$OUTFILE" ]; then |
35 "$DUMPSYMS" "$INFILE" > "$OUTFILE" | 37 "$DUMPSYMS" "$INFILE" > "$OUTFILE" |
36 fi | 38 fi |
37 | 39 |
38 # Strip the binary and calculate the signature of that, since that's what ships. | 40 # Strip the binary and calculate the signature of that, since that's what ships. |
39 strip "$INFILE" -o "$STRIPPED" | 41 strip "$INFILE" -o "$STRIPPED" |
40 NEWSIG=$("$SCRIPTDIR/dump_signature.py" "$STRIPPED") | 42 NEWSIG=$("$SCRIPTDIR/dump_signature.py" "$STRIPPED") |
41 rm "$STRIPPED" | 43 if [ "$KEEP_STRIPPED_BINARY" != "0" ]; then |
| 44 mv "$STRIPPED" "$INFILE" |
| 45 else |
| 46 rm "$STRIPPED" |
| 47 fi |
42 | 48 |
43 # Replace the old signature with the stripped signature in the symbols file. | 49 # Replace the old signature with the stripped signature in the symbols file. |
44 sed -i "1s/ [0-9A-F]* / $NEWSIG /" "$OUTFILE" | 50 sed -i "1s/ [0-9A-F]* / $NEWSIG /" "$OUTFILE" |
OLD | NEW |