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

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)"
15
16 ADB=adb
17 if [[ x$1 != x ]]; then
Alexander Potapenko 2014/01/17 12:43:50 Better quote both operands.
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 cat <<EOF >"$TMPDIR/app_process"
53 #!/system/bin/sh
54 ASAN_OPTIONS=strict_memcmp=0,malloc_context_size=3,start_deactivated=1 \\
55 LD_PRELOAD=libclang_rt.asan-arm-android.so \\
56 exec /system/bin/app_process.real \$@
57
58 EOF
59
60 cat <<EOF >"$TMPDIR/asanwrapper"
61 #!/system/bin/sh
62 ASAN_OPTIONS=strict_memcmp=0 \
63 LD_PRELOAD=libclang_rt.asan-arm-android.so \
64 exec \$@
65
66 EOF
67
68 echo '>> Pushing files to the device'
69 $ADB push "$ASAN_RT" /system/lib/
70 $ADB push "$TMPDIR/app_process" /system/bin/app_process
71 $ADB push "$TMPDIR/app_process.real" /system/bin/app_process.real
72 $ADB push "$TMPDIR/asanwrapper" /system/bin/asanwrapper
73 $ADB shell chown root.shell \
74 /system/bin/app_process \
75 /system/bin/app_process.real \
76 /system/bin/asanwrapper
77 $ADB shell chmod 755 \
78 /system/bin/app_process \
79 /system/bin/app_process.real \
80 /system/bin/asanwrapper
81
82 rm -r "$TMPDIR"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698