use of org.mapleir.deob.interproc.IRCallTracer in project maple-ir by LLVM-but-worse.
the class Boot method main.
public static void main(String[] args) throws Exception {
sections = new LinkedList<>();
logging = true;
File rtjar = new File("res/rt.jar");
// Load input jar
File f = locateRevFile(135);
// File f = new File("res/allatori6.1san.jar");
section("Preparing to run on " + f.getAbsolutePath());
SingleJarDownloader<ClassNode> dl = new SingleJarDownloader<>(new JarInfo(f));
dl.download();
String name = f.getName().substring(0, f.getName().length() - 4);
// ApplicationClassSource app = new ApplicationClassSource(name, dl.getJarContents().getClassContents());
//
ApplicationClassSource app = new ApplicationClassSource("test", ClassHelper.parseClasses(CGExample.class));
// app.addLibraries(new InstalledRuntimeClassSource(app));
app.addLibraries(rt(app, rtjar), new InstalledRuntimeClassSource(app));
section("Initialising context.");
AnalysisContext cxt = new BasicAnalysisContext.BasicContextBuilder().setApplication(app).setInvocationResolver(new DefaultInvocationResolver(app)).setCache(new IRCache(ControlFlowGraphBuilder::build)).setApplicationContext(new SimpleApplicationContext(app)).build();
section("Expanding callgraph and generating cfgs.");
IRCallTracer tracer = new IRCallTracer(cxt);
for (MethodNode m : cxt.getApplicationContext().getEntryPoints()) {
// System.out.println(m);
tracer.trace(m);
if (m.instructions.size() > 500 && m.instructions.size() < 100) {
System.out.println(m);
System.out.println(cxt.getIRCache().get(m));
}
}
for (ClassNode cn : app.iterate()) {
TabbedStringWriter sw = new TabbedStringWriter();
sw.setTabString(" ");
IPropertyDictionary settings = PropertyHelper.createDictionary();
// settings.put(new BooleanProperty(ASMPrinter.PROP_ACCESS_FLAG_SAFE, true));
ClassPrinter cp = new ClassPrinter(sw, settings, new FieldNodePrinter(sw, settings), new MethodNodePrinter(sw, settings) {
@Override
protected ControlFlowGraph getCfg(MethodNode mn) {
return cxt.getIRCache().getFor(mn);
}
});
cp.print(cn);
System.out.println(sw.toString());
}
section0("...generated " + cxt.getIRCache().size() + " cfgs in %fs.%n", "Preparing to transform.");
// do passes
PassGroup masterGroup = new PassGroup("MasterController");
for (IPass p : getTransformationPasses()) {
masterGroup.add(p);
}
run(cxt, masterGroup);
// for(MethodNode m : cxt.getIRCache().getActiveMethods()) {
// if(m.instructions.size() > 100 && m.instructions.size() < 500) {
// System.out.println(cxt.getIRCache().get(m));
// }
// }
section("Retranslating SSA IR to standard flavour.");
for (Entry<MethodNode, ControlFlowGraph> e : cxt.getIRCache().entrySet()) {
MethodNode mn = e.getKey();
ControlFlowGraph cfg = e.getValue();
BoissinotDestructor.leaveSSA(cfg);
cfg.getLocals().realloc(cfg);
(new ControlFlowGraphDumper(cfg, mn)).dump();
}
section("Rewriting jar.");
// dumpJar(app, dl, masterGroup, "out/osb5.jar");
section("Finished.");
}
Aggregations