media/webrtc/trunk/build/gdb-add-index

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #!/bin/bash
michael@0 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
michael@0 3 # Use of this source code is governed by a BSD-style license that can be
michael@0 4 # found in the LICENSE file.
michael@0 5 #
michael@0 6 # Saves the gdb index for a given binary and its shared library dependencies.
michael@0 7
michael@0 8 set -e
michael@0 9
michael@0 10 if [[ ! $# == 1 ]]; then
michael@0 11 echo "Usage: $0 path-to-binary"
michael@0 12 exit 1
michael@0 13 fi
michael@0 14
michael@0 15 FILENAME="$1"
michael@0 16 if [[ ! -f "$FILENAME" ]]; then
michael@0 17 echo "Path $FILENAME does not exist."
michael@0 18 exit 1
michael@0 19 fi
michael@0 20
michael@0 21 # We're good to go! Create temp directory for index files.
michael@0 22 DIRECTORY=$(mktemp -d)
michael@0 23 echo "Made temp directory $DIRECTORY."
michael@0 24
michael@0 25 # Always remove directory on exit.
michael@0 26 trap "{ echo -n Removing temp directory $DIRECTORY...;
michael@0 27 rm -rf $DIRECTORY; echo done; }" EXIT
michael@0 28
michael@0 29 # Grab all the chromium shared library files.
michael@0 30 so_files=$(ldd "$FILENAME" 2>/dev/null \
michael@0 31 | grep $(dirname "$FILENAME") \
michael@0 32 | sed "s/.*[ \t]\(.*\) (.*/\1/")
michael@0 33
michael@0 34 # Add index to binary and the shared library dependencies.
michael@0 35 for file in "$FILENAME" $so_files; do
michael@0 36 basename=$(basename "$file")
michael@0 37 echo -n "Adding index to $basename..."
michael@0 38 readelf_out=$(readelf -S "$file")
michael@0 39 if [[ $readelf_out =~ "gdb_index" ]]; then
michael@0 40 echo "already contains index. Skipped."
michael@0 41 else
michael@0 42 gdb -batch "$file" -ex "save gdb-index $DIRECTORY" -ex "quit"
michael@0 43 objcopy --add-section .gdb_index="$DIRECTORY"/$basename.gdb-index \
michael@0 44 --set-section-flags .gdb_index=readonly "$file" "$file"
michael@0 45 echo "done."
michael@0 46 fi
michael@0 47 done

mercurial