本文依旧参考自 soot 的 tutorial :On the Soot menagerie - fundamental Soot objects 。文中会介绍 Body, Unit, Local, UnitBox 和 ValueBox。
所有Body
Body 是用于存放 method 代码的。根据中间代码的不同可以有 BafBody, JimpleBody 和 GrimpBody 三种。Body 中有3种主要的 chain,分别是 Unit chain,Local chain 和 Trap chain。
以下是一段 Java 代码以及其对应的 Jimple 代码:
public static void main(String[] argv) throws Exception
{
int x = 2, y = 6;
System.out.println("Hi!");
System.out.println(x * y + y);
try
{
int z = y * x;
}
catch (Exception e)
{
throw e;
}
}
public static void main(java.lang.String[]) throws java.lang.Except