-----------------------------
| Installation Instructions |
-----------------------------

1. Download DOOP (r160113) and soot-fact-generation (r958) from http://doop.program-analysis.org/download.html.

2. Unzip DOOP and soot-fact-generation, then set environment variable DOOP_HOME to the directory where you unpack DOOP by:
   $ export DOOP_HOME=unpack_directory/doop-r160113-bin/

3. Download sootclasses-2.5.0.jar from http://www.sable.mcgill.ca/software/sootclasses-2.5.0.jar and then
   put it in $DOOP_HOME/lib/ directory. (DOOP (r160113) provides sootclasses-2.3.0.jar, ELF's facts generator
   needs sootclasses-2.5.0.jar)

4. Download elf.patch to $DOOP_HOME and then apply it to DOOP by:
   $ cd $DOOP_HOME
   $ patch -p1 < elf.patch

5. Download gen.patch to soot-fact-generation directory and then switch to soot-fact-generation directory, write:
   $ patch -p1 < gen.patch
   $ ./compile
   $ ./install

Now, the ELF has been installed on the top of DOOP.

In addition, to run ELF, users should follow the instructions in $DOOP_HOME/README to setup the 
applications and library (to be analyzed) and configure the corresponding paths.

----------
| Usages |
----------

ELF has the similiar usage with DOOP, except that you cannot use -disable-reflection, -disable-reflective-methods
and -distinguish-no-string-constants options.

In addition, ELF adds a "-generate-soot-reflection-log" option which enable ELF to output its reflection analysis
results with a format which is supported by Soot so that ELF can make use of SOLAR. Please see details in next section.

By default, ELF distinguishes a string constants if it is a class name, a method name or a field name. For fairly
comparing with DOOP, ELF treats the string constants which represent method names or field names as one string
constant while computing the size of points-to set.


-----------------------
| Using ELF with Soot |
-----------------------

It just takes two steps to use ELF to facilitate the static analysis with Soot.

Step 1: Running ELF and generating reflection log
---------------------------------------------------------------------

To let ELF create reflection log file, you can use the option "-generate-soot-reflection-log"
which is mentioned above, and then ELF will output its reflection analysis results into a
log file.

The log file name is the name of the main class of the program to be analyzed plus ".log" as suffix.

For example, let us use ELF to analyze luindex benchmark of DaCapo:  

$ ./run -jre1.6 -generate-soot-reflection-log 1-call-site-sensitive jars/dacapo/luindex.jar
$ ...
$ generating reflection log for Soot at dacapo.luindex.Main.log
$ ...

Now, ELF has output its reflection analysis results to dacapo.luindex.Main.log.


Step 2: Running Soot with the reflection log generated by ELF
---------------------------------------------------------------------

To use the reflection analysis results of ELF with Soot, you just need to give Soot the log
file generated by ELF by using the option "reflection-log".

Soot provides the option "reflection-log" in call graph construction phase to load
a reflection log from the given file and use it to resolve reflective call sites. 

For example, let us use Soot to analyze luindex with reflection log from ELF: 

$ java -cp soot-2.5.0.jar soot.Main \			# run Soot
-w -app -p cg.spark enabled \					# enable Spark
-p cg reflection-log:dacapo.luindex.Main.log \	# use the reflection log from ELF
-cp luindex.jar:${JRE}/jce.jar:${JRE}/rt.jar \	# set up class path for Soot
-main-class dacapo.luindex.Main \				# specify main class
dacapo.luindex.Main


------------------------
| Main changes to DOOP |
------------------------

- soot-fact-generation/src/FactWriter.java, FactGenerator.java, PostDominatorFinder.java
  Generate more facts for reflection analysis, such as the ones involving post dominance.

- gen-import
  Import more facts for reflection analysis.  

- logic/library/elf/propagation.logic
  New added file which contains rules for resolving reflective calls by target propagation.

- logic/library/elf/inference.logic
  New added file which includes rules for resolving reflective calls by target inference.

- logic/library/elf/array.logic
  New added file which contains rules for handling methods of java.lang.reflect.Array.
  
- logic/library/elf/reflect-stats.logic
  New added file which contains rules for collecting reflection analysis results.
  
  
- logic/context-sensitive.logic
- logic/library/reflective.logic
  Fix unsound handling of argument passing for reflective invocation.

- logic/library/reflection-delta.logic
  Add place holders for helping target inference.

- logic/library/string-constants.logic
  Distinguish string constants whose values equal method names or field names.


- scripts/get-refl-targets.py
- scripts/soot-converter.py
  New added scripts for assisting ELF output its results.
  
- run
  Add "-ssa" option to fact generator arguments.

- stats-simple
  Output reflection analysis results.


Please feel free to contact the authors if you have any concerns.
