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