[Soot-list] How to transform a Grimp file into class file

Bodden, Eric eric.bodden at sit.fraunhofer.de
Mon Oct 28 13:49:23 EDT 2013


> "-validate" option still give me the same error.


Hmm, in this case it is hard to tell. The Grimp code you generate is probably ill-formed. However, I have no idea what is and what is not allowed in Grimp - I have never used it myself. Therefore it's hard to tell for me.

Eric

> 
> Best regards,
> Yongzhi
> 
> 
> On Mon, Oct 28, 2013 at 10:14 AM, Bodden, Eric <eric.bodden at sit.fraunhofer.de> wrote:
> Hello.
> 
> Can you please try the -validate option? That way Soot usually catches malformed code earlier.
> 
> Cheers,
> Eric
> 
> On 28.10.2013, at 13:53, Yongzhi Wang <wang.yongzhi2009 at gmail.com> wrote:
> 
> > Dear Eric,
> >
> > Thanks for your information. I tried --via-grimp option:
> >
> > java -Xms512M -Xmx1024M -cp $SOOT_HOME/jasminclasses-custom.jar:$SOOT_HOME/polyglotclasses-1.3.5.jar:$SOOT_HOME/soot-trunk.jar:/Users/yongzhiwang/Documents/develop/soot_build/ExpObf.jar  edu.fiu.YwangMain -cp .:$MAC_JRE_HOME/ut.jar:$MAC_JRE_HOME/classes.jar:$MAC_JRE_HOME/jce.jar -w --via-grimp -src-prec c -f c -include-all -process-dir ./Test/bin -output-dir Test/soot_output/
> >
> >
> > However, when I generate class file, I get  the following error:
> >
> > Writing to Test/soot_output/Sub.class
> > Exception in thread "main" java.lang.RuntimeException: Stack height is negative!
> >       at soot.jimple.JasminClass.modifyStackHeight(JasminClass.java:55)
> >       at soot.jimple.JasminClass.emit(JasminClass.java:43)
> >       at soot.jimple.JasminClass$4$6.caseDoubleType(JasminClass.java:1212)
> >       at soot.DoubleType.apply(DoubleType.java:60)
> >       at soot.jimple.JasminClass$4.caseGeExpr(JasminClass.java:1183)
> >       at soot.grimp.internal.GGeExpr.apply(GGeExpr.java:43)
> >       at soot.jimple.JasminClass.emitIfStmt(JasminClass.java:878)
> >       at soot.jimple.JasminClass$5.caseIfStmt(JasminClass.java:1316)
> >       at soot.jimple.internal.JIfStmt.apply(JIfStmt.java:139)
> >       at soot.jimple.JasminClass.emitStmt(JasminClass.java:1242)
> >       at soot.jimple.JasminClass.emitMethodBody(JasminClass.java:487)
> >       at soot.AbstractJasminClass.emitMethod(AbstractJasminClass.java:697)
> >       at soot.AbstractJasminClass.<init>(AbstractJasminClass.java:576)
> >       at soot.jimple.JasminClass.<init>(JasminClass.java:63)
> >       at soot.PackManager.writeClass(PackManager.java:941)
> >       at soot.PackManager.writeOutput(PackManager.java:522)
> >       at soot.PackManager.writeOutput(PackManager.java:431)
> >       at soot.Main.run(Main.java:200)
> >       at soot.Main.main(Main.java:141)
> >
> > This error should relate to my transformed if statement. The grimp body of the if statement is :
> >
> > int i0, i1, i2;
> >
> > if java.lang.Math.pow(i1 + 6.084327287303699, i1 + 2.652800753429542) > 120.32605826124878 goto label0;
> >
> > The method that I generate such if statement is as follows:
> >
> > SootClass mathClass = Scene.v().loadClassAndSupport("java.lang.Math");
> > SootMethod toCall = mathClass.getMethodByName("pow");
> >             params.add(baseValue);
> >             params.add(indexValue);
> > InvokeExpr expoExpr= Grimp.v().newStaticInvokeExpr(toCall.makeRef(), params);
> >
> > Do you have any idea about the error? I was wondering if the statement generation method is correct or not. Thanks!
> >
> > Best regards,
> > Yongzhi
> >
> >
> > On Mon, Oct 28, 2013 at 4:53 AM, Bodden, Eric <eric.bodden at sit.fraunhofer.de> wrote:
> > Hi.
> >
> > Please try the -via-grimp option:
> > http://www.sable.mcgill.ca/soot/tutorial/usage/
> >
> > This should give you GrimpBody instances in general, which can then hold Grimp instructions.
> >
> > Cheers,
> > Eric
> >
> >
> > On 24.10.2013, at 23:43, Yongzhi Wang <wang.yongzhi2009 at gmail.com> wrote:
> >
> > > Dear All,
> > >
> > > I want to transform java program into a class file with some manipulations. My original transformation step is as follows. The transformation is performed in "jtp" step.
> > >
> > > Java --> Jimple --> class
> > >
> > > However, since Jimple can only accommodate three operators in each expression. I create some Grimp expressions (using Grimp.v().newXXX() function) during the java to jimple transformation. Therefore, the generated jimple file contains statements containing more than three operators. When I transform the generated Jimple into class, I got the following error.
> > >
> > > My question is how can I transform my generated jimple file (containing multiple operators) into class file? Or I simply shouldn't use the Grimp.v().newXXX() functions in the jtp transformation step? I know I can transform the generated expressions into jimple standard three operator format. However, I just want to see if there's any quicker way as I tried.
> > >
> > > java.lang.reflect.InvocationTargetException
> > >       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > >       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > >       at java.lang.reflect.Method.invoke(Method.java:597)
> > >       at ca.mcgill.sable.soot.launching.SootThread.run(SootThread.java:138)
> > > Caused by: java.lang.ClassCastException: soot.grimp.internal.GAddExpr cannot be cast to soot.jimple.ConvertToBaf
> > >       at soot.jimple.internal.AbstractStaticInvokeExpr.convertToBaf(AbstractStaticInvokeExpr.java:135)
> > >       at soot.jimple.internal.JIfStmt.convertToBaf(JIfStmt.java:277)
> > >       at soot.baf.BafBody.<init>(BafBody.java:104)
> > >       at soot.baf.Baf.newBody(Baf.java:560)
> > >       at soot.PackManager.runBodyPacks(PackManager.java:793)
> > >       at soot.PackManager.runBodyPacks(PackManager.java:463)
> > >       at soot.PackManager.runBodyPacks(PackManager.java:380)
> > >       at soot.PackManager.runPacks(PackManager.java:357)
> > >       at soot.Main.run(Main.java:198)
> > >       at soot.Main.main(Main.java:141)
> > >
> > > Thanks!
> > >
> > > Yongzhi
> > > _______________________________________________
> > > Soot-list mailing list
> > > Soot-list at sable.mcgill.ca
> > > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> >
> > --
> > Prof. Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
> > Head of Secure Software Engineering  at Fraunhofer SIT, TU Darmstadt and EC SPRIDE
> > Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
> > Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
> >
> >
> 
> --
> Prof. Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
> Head of Secure Software Engineering  at Fraunhofer SIT, TU Darmstadt and EC SPRIDE
> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
> 
> 

--
Prof. Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
Head of Secure Software Engineering  at Fraunhofer SIT, TU Darmstadt and EC SPRIDE
Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt



More information about the Soot-list mailing list