Soot .class .jimple .java commandline args Soot Polyglot - - PowerPoint PPT Presentation

soot
SMART_READER_LITE
LIVE PREVIEW

Soot .class .jimple .java commandline args Soot Polyglot - - PowerPoint PPT Presentation

Soot .class .jimple .java commandline args Soot Polyglot Jimpilfy Jimple Parser Frontend Jimple Analysis and Transformations Jimple, with Flow Analysis Information Add tags Jimple with Tags Generate Jimple Files Generate


slide-1
SLIDE 1

Soot

Soot

Jimpilfy Polyglot Front−end Analysis and Transformations Add tags Generate Bytecode Decompile to Java Jimple Parser

Jimple Jimple, with Flow Analysis Information Jimple with Tags

and Attributes in xml Generate Jimple Files command−line args .class .java .class .java .xml .jimple .jimple

Soot can now also take Android bytecode as input and generate Android bytecode as output

slide-2
SLIDE 2

Soot Resources

Soot main page: http://sable.github.io/soot/ Soot download page: http: //www.sable.mcgill.ca/soot/soot_download.html Soot tutorials: https://github.com/Sable/soot/wiki/Tutorials (Temporarily: soot-2.5.0.jar is available through the course website)

slide-3
SLIDE 3

Installing Soot

Command-line Soot Download soot-2.5.0.jar and add to CLASSPATH environment variable: export CLASSPATH=soot-2.5.0.jar:$CLASSPATH Soot-Eclipse plugin Follow installation instructions at: https://github.com/ Sable/soot/wiki/Running-Soot-as-Eclipse-Plugin

slide-4
SLIDE 4

Command-line Examples

List command line options java soot.Main --help Process MyClass.class, output .class file java soot.Main MyClass Process MyClass.class, output .jimple file java soot.Main -f jimple MyClass Process MyClass.java, output .class file java soot.Main -src-prec java MyClass Process MyClass.class, output .jimple file with tags java soot.Main -f jimple -print-tags MyClass

slide-5
SLIDE 5

Command-line Examples Warning

Soot has its own class path and loads only classes from that path. java soot.Main MyClass will not run. Use the -cp option to Soot to specify a path: java soot.Main -cp . MyClass will still not run Need to provide Java library classes: java soot.Main -cp .:<path-to-rt.jar> MyClass will run

slide-6
SLIDE 6

Jimple Statements

slide-7
SLIDE 7

Jimple Expressions

slide-8
SLIDE 8

Soot Classes

SootClass SootMethod JimpleBody Scene SootField getMethod() getField() getSootClass() Scene.v() (singleton) getSignature() getActiveBody() getSignature()

slide-9
SLIDE 9

Soot Classes

SootMethod Chain Chain Chain JimpleBody UnitGraph getLocals() getActiveBody() getTraps() getUnits() getBody() getUnits() new BriefUnitGraph()

slide-10
SLIDE 10

“Boxes” (References)

s: x = y op z

slide-11
SLIDE 11
slide-12
SLIDE 12

Soot Attributes

We often want to attach annotations to code

to convey low-level analysis results, such as register allocation or array bounds check elimination to a VM to convey analysis results to humans to record profiling information

slide-13
SLIDE 13

Tags

Tags are objects that can be attached to Hosts:

package soot.tagkit; public interface Tag { public String getName (); public String toString(); }

slide-14
SLIDE 14

Hosts

Hosts are objects that can hold Tags:

package soot.tagkit; public interface Host { public void addTag (Tag t); public Tag getTag (String aName); public List getTags (); public void removeTag (String name); public boolean hasTag (String aName); }

Implementations:

SootClass, SootField, SootMethod, Body, Unit, ValueBox

slide-15
SLIDE 15

Visual Representations

Three visual representations of attribute information:

Text displayed in tooltips Color highlighting of chunks of code Pop-up links

slide-16
SLIDE 16

String Tags

StringTags attach a string of information to a Host. s.addTag(new StringTag(val+": NonNull"));

slide-17
SLIDE 17

Color Tags

ColorTags attach a color to a Host. v.addTag(new ColorTag(ColorTag.GREEN)); v.addTag(new ColorTag(255, 0, 0));

slide-18
SLIDE 18

Link Tags

LinkTags attach a string of information, and a link to another part of code to a Host. SootMethod m; String text = "Target:"+m.toString(); Host h = m; String cName = m.getDeclaringClass().getName(); s.addTag(new LinkTag(text, h, cName));