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>" | 13 echo "$0 <dump_syms_exe> <binary_with_symbols> <symbols_output>" >&2 |
14 } | 14 } |
15 | 15 |
16 | 16 |
17 if [ $# -ne 3 ]; then | 17 if [ $# -ne 3 ]; then |
18 usage | 18 usage |
19 exit 1 | 19 exit 1 |
20 fi | 20 fi |
21 | 21 |
22 SCRIPTDIR="$(readlink -f "$(dirname "$0")")" | 22 SCRIPTDIR="$(readlink -f "$(dirname "$0")")" |
23 DUMPSYMS="$1" | 23 DUMPSYMS="$1" |
24 INFILE="$2" | 24 INFILE="$2" |
25 OUTFILE="$3" | 25 OUTFILE="$3" |
26 | 26 |
27 STRIPPED=$(mktemp -q -t stripped-XXXXX) | 27 STRIPPED=$(mktemp -q -t stripped-XXXXX) |
28 if [ $? -ne 0 ]; then | 28 if [ $? -ne 0 ]; then |
29 echo "ERROR: Could not create temp stripped '$INFILE'" | 29 echo "ERROR: Could not create temp stripped '$INFILE'" >&2 |
30 exit 1 | 30 exit 1 |
31 fi | 31 fi |
32 | 32 |
33 # Dump the symbols from the given binary. | 33 # Dump the symbols from the given binary. |
34 "$DUMPSYMS" "$INFILE" > "$OUTFILE" | 34 if [ "$INFILE" -nt "$OUTFILE" ]; then |
| 35 "$DUMPSYMS" "$INFILE" > "$OUTFILE" |
| 36 fi |
35 | 37 |
36 # Strip the binary and calculate the signature of that, since that's what ships. | 38 # Strip the binary and calculate the signature of that, since that's what ships. |
37 strip "$INFILE" -o "$STRIPPED" | 39 strip "$INFILE" -o "$STRIPPED" |
38 NEWSIG=$("$SCRIPTDIR/dump_signature.py" "$STRIPPED") | 40 NEWSIG=$("$SCRIPTDIR/dump_signature.py" "$STRIPPED") |
39 rm "$STRIPPED" | 41 rm "$STRIPPED" |
40 | 42 |
41 # Replace the old signature with the stripped signature in the symbols file. | 43 # Replace the old signature with the stripped signature in the symbols file. |
42 INFILE_BASE=$(basename "$INFILE") | 44 sed -i "1s/ [0-9A-F]* / $NEWSIG /" "$OUTFILE" |
43 sed -i "1s/[0-9A-F]* $INFILE_BASE/$NEWSIG $INFILE_BASE/" "$OUTFILE" | |
44 | |
OLD | NEW |