Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tools/android/asan/asan_device_setup.sh

Issue 138153003: Switch to the "new" way of ASan deployment on Android devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/bin/bash
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 # Prepare Android device to run ASan application.
7 #
8 # To revert this setup,
9 # adb remount
10 # adb shell mv /system/bin/app_process.real /system/bin/app_process
11 # adb shell rm /system/bin/asanwrapper
12 # adb shell rm /system/lib/libclang_rt.asan-arm-android.so
13
14 HERE="$(cd "$(dirname "$0")" && pwd)"
bulach 2014/01/17 13:27:53 every time we start with bash scripts, we end up c
frankf 2014/01/18 01:55:57 Seconded. But I'm OK with doing the conversion as
eugenis 2014/01/20 13:51:18 This is definitely meant to be used as a standalon
15
16 ADB=adb
17 if [[ x$1 != x ]]; then
18 ADB="adb -s $1"
19 fi
20
21 TMPDIR=$(mktemp -d)
22 echo $TMPDIR
23
24 ASAN_RT_PATH="$HERE"
25 ASAN_RT="$ASAN_RT_PATH/libclang_rt.asan-arm-android.so"
26
27 if ! [[ -f "$ASAN_RT" ]]; then
28 echo "ASan runtime library not found at $ASAN_RT"
29 exit 1
30 fi
31
32 echo '>> Remounting /system rw'
33 $ADB remount
34
35 echo '>> Copying files from the device'
36 $ADB pull /system/bin/app_process "$TMPDIR/app_process"
37 $ADB pull /system/bin/app_process.real "$TMPDIR/app_process.real"
38
39 if ! [[ -f "$TMPDIR/app_process" ]]; then
40 echo "app_process missing???"
41 exit 1
42 fi
43
44 if [[ -f "$TMPDIR/app_process.real" ]]; then
45 echo "app_process.real exists, updating the wrapper"
46 else
47 echo "app_process.real missing, new installation"
48 mv "$TMPDIR/app_process" "$TMPDIR/app_process.real"
49 fi
50
51 echo '>> Generating wrappers'
52 # Zygote wrapper.
53 cat <<EOF >"$TMPDIR/app_process"
54 #!/system/bin/sh
55 ASAN_OPTIONS=strict_memcmp=0,malloc_context_size=3,start_deactivated=1 \\
56 LD_PRELOAD=libclang_rt.asan-arm-android.so \\
57 exec /system/bin/app_process.real \$@
58
59 EOF
60
61 # General command-line tool wrapper (use for anything that's not started as
62 # zygote).
63 cat <<EOF >"$TMPDIR/asanwrapper"
64 #!/system/bin/sh
65 ASAN_OPTIONS=strict_memcmp=0 \
66 LD_PRELOAD=libclang_rt.asan-arm-android.so \
67 exec \$@
68
69 EOF
70
71 echo '>> Pushing files to the device'
72 $ADB push "$ASAN_RT" /system/lib/
73 $ADB push "$TMPDIR/app_process" /system/bin/app_process
74 $ADB push "$TMPDIR/app_process.real" /system/bin/app_process.real
75 $ADB push "$TMPDIR/asanwrapper" /system/bin/asanwrapper
76 $ADB shell chown root.shell \
77 /system/bin/app_process \
78 /system/bin/app_process.real \
79 /system/bin/asanwrapper
80 $ADB shell chmod 755 \
81 /system/bin/app_process \
82 /system/bin/app_process.real \
83 /system/bin/asanwrapper
84
85 rm -r "$TMPDIR"
bulach 2014/01/17 13:27:53 nit: if people would be running this as a standalo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698