[Soot-list] loading classes properly

Peter Kim chpkim at gmail.com
Wed Feb 18 16:56:21 EST 2015


Hi,

I want to construct a call graph from an entry point, making sure all the
classes transitively referenced are loaded along the way. I thought
forceResolve() should do the trick, but despite calling it using the
following code, I'm still getting some important edges. Could you please
tell me if this is the correct way to do so? I don't want any phantom
classes and methods. I have all the necessary class files so I shouldn't be
getting these. Also, could you please tell me the relationship between
"addBasicClass()" and rt.jar? If I have the jar in my soot classpath, which
classes still need to be added through "addBasicClass()"? Thanks.

soot.G.reset();

Scene.v().addBasicClass("java.lang.IllegalArgumentException",
SootClass.SIGNATURES);
Scene.v().addBasicClass("java.lang.CloneNotSupportedException",
SootClass.SIGNATURES);
Scene.v().addBasicClass("java.lang.InterruptedException",
SootClass.SIGNATURES);
Scene.v().addBasicClass("java.lang.StringBuilder", SootClass.SIGNATURES);
Scene.v().addBasicClass("java.lang.CharSequence", SootClass.SIGNATURES);
Scene.v().addBasicClass("java.security.Security", SootClass.SIGNATURES);
Scene.v().addBasicClass("java.io.PrintWriter", SootClass.SIGNATURES);
Scene.v().addBasicClass("java.util.Locale", SootClass.SIGNATURES);
                // ....
 Options.v().set_no_bodies_for_excluded(true);
Options.v().set_allow_phantom_refs(false);

Options.v().set_soot_classpath(classesToAnalyze + File.pathSeparator +
RT_JAR);
Options.v().set_process_dir(Collections.singletonList(classesToAnalyze));

Options.v().setPhaseOption("cg.spark", "on");
Options.v().setPhaseOption("cg.spark", "string-constants:true");
Options.v().set_whole_program(true);
Options.v().setPhaseOption("cg", "trim-clinit:false");
// do not merge variables (causes problems with PointsToSets)
Options.v().setPhaseOption("jb.ulp", "off");
Options.v().set_src_prec(Options.src_prec_class);

// Set entry point
SootClass mainClass = Scene.v().forceResolve(SOME_METHOD, SootClass.BODIES);
mainClass.setApplicationClass();
Scene.v().loadNecessaryClasses();
mainMethod = mainClass.getMethodByName(MAIN_METHOD_NAME);
Scene.v().setEntryPoints(Collections.singletonList(mainMethod));

// Patch the java.lang.Thread implementation
patchThreadImplementation();

PackManager.v().getPack("wjpp").apply();
PackManager.v().getPack("cg").apply();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150218/4d7cd853/attachment.html 


More information about the Soot-list mailing list