Information Technology Reference
In-Depth Information
-pp
: This option prepends the VM's classpath to Soot's own classpath.
-validate
: Causes sanity checks to be performed on Jimple bodies to make
sure the transformations have caused no type errors. This option may de-
grade Soot's performance, but might be useful for debugging instrumentation
code.
-output-format
format
: Specifies the format of output files Soot should
produce, if any. In case of Android instrumentation, the
dex
format has to be
set. For debugging purposes, one can use the
jimple
output format to inspect
the instrumentation results in the intermediate language. Note, though, that
one cannot create outputs in multiple formats at the same time.
-process-dir
dirs
:Addsallclassesin
dirs
to the set of classes to be
analyzed and transformed by Soot. The list
dirs
can also contain
jar
or
apk
files.
-src-prec
format
: Sets format as Soot's preference for the type of source
files to read when it looks for a class. In the case of Android, the
apk
format
must be set.
-w
: Tells Soot to enable the whole-program transformation packs. Required
if one requires a callgraph or wants to use the
wjtp
pack for performing global
transformations spanning multiple methods.
-allow-phantom-refs
: Allows Soot to model classes not found on the class-
path by stubs containing no methods or fields. Useful for saving memory by
not including full implementations of some libraries.
These options can either be set via the command line or directly in the Java
code via
Options.v()
, e.g.,
Options.v().set whole program(true)
for en-
abling whole-program mode if required. Listing 1.10 shows an example of a
possible Soot initialization for instrumenting Android applications.
1
private static boolean
SOOT_INITIALIZED =
false
;
2
private final static
String androidJAR =
"./lib/android.jar"
;
3
private
final static
String apk =
"./apk/RV2013.apk"
;
4
5
public
static void
initialiseSoot(){
6
if
(SOOT_INITIALIZED)
7
return
;
8
9
Options.v().set_allow_phantom_refs(
true
);
10
Options.v().set_prepend_classpath(
true
);
11
Options.v().set_validate(
true
);
12
13
Options.v().set_output_format(Options.output_format_dex);
14
Options.v().set_process_dir(Collections.singletonList(apk));
15
Options.v().set_force_android_jar(androidJAR);
16
Options.v().set_src_prec(Options.src_prec_apk);
17
18
Options.v().set_soot_classpath(androidJAR);
19
20
Scene.v().loadNecessaryClasses();
21
22
SOOT_INITIALIZED =
true
;
23
}
Listing 1.10.
Soot Initialization Example for Instrumenting Android Applications