Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/metaproject #86

Draft
wants to merge 80 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
3b3e206
Improved IFDS analysis, including demos and tests; by Mario Trageser
errt Mar 5, 2021
eb91c75
Merge branch 'develop' into feature/IDFS-improvements
errt May 27, 2021
31c4c6b
Create new project "ll"
buenaventure Jun 29, 2021
a26ee83
Add llvm bindings dependency
buenaventure Jun 29, 2021
9490098
Merge branch 'develop' into feature/IDFS-improvements
TorunR Jun 30, 2021
1a3b939
Read and dump module
buenaventure Jul 5, 2021
34d4e25
Begin implementing wrappers
buenaventure Jul 6, 2021
53da4de
Read instructions
buenaventure Jul 7, 2021
283ef68
AndroidEntryPointFinder added
Diarilex Jul 14, 2021
c88385a
Implement SimplePurityAnalysis which assumes everything to be Impure
buenaventure Nov 8, 2021
bca47d7
Merge branch 'develop' into feature/IDFS-improvements
TorunR Nov 10, 2021
c87f9ac
Implement SimplePurityAnalysis
buenaventure Nov 12, 2021
df11561
Implement viewCFG
buenaventure Nov 12, 2021
75f01ea
Merge pull request #3 from buenaventure/develop
buenaventure Dec 2, 2021
79cf52a
Merge remote-tracking branch 'upstream/develop' into ll
buenaventure Jan 5, 2022
905ad98
Add simple multilingual test project
buenaventure Jan 6, 2022
c624d84
Merge remote-tracking branch 'upstream/develop' into feature/IDFS-imp…
buenaventure Feb 17, 2022
bb079fd
Merge branch 'develop' into ll
buenaventure Feb 17, 2022
9ccee79
Add taint testcase
buenaventure Feb 5, 2022
6ab61f6
Merge branch 'feature/IDFS-improvements' into ll_multiling_ifds
buenaventure Feb 18, 2022
b99997c
Format code
buenaventure Feb 18, 2022
90c179a
Adapt new ifds to new call graph (with context)
buenaventure Feb 21, 2022
a464309
Add multilingual taint test
buenaventure Feb 23, 2022
7d00973
Extract IFDSProblem(flow functions etc) from IFDSAnalysis
buenaventure Mar 2, 2022
e3838cf
Replace specialized ifds analysis classes with parameter
buenaventure Mar 2, 2022
633c377
WIP
buenaventure Mar 5, 2022
cc84ea1
WIP
buenaventure Mar 10, 2022
cb4f4f7
WIP
buenaventure Mar 10, 2022
41d949c
WIP
buenaventure Mar 11, 2022
0b40422
WIP
buenaventure Mar 16, 2022
54bb807
WIP
buenaventure Mar 16, 2022
76a1c27
WIP (compiles)
buenaventure Mar 17, 2022
2bfaeea
Initialization fix
buenaventure Mar 17, 2022
6df8fab
Implement LLVM Argument, Type(s); Better Function/Instruction represe…
buenaventure Mar 18, 2022
f92c953
Move IFDS into separate project; Refactor handling of calls outside o…
buenaventure Mar 18, 2022
3931605
Re-implement ifds solver
buenaventure Mar 24, 2022
3ee3a04
Use new implementation for native part
buenaventure Mar 24, 2022
25d0f19
Implement forward taint analysis as test for new ifds solver
buenaventure Mar 25, 2022
3283b03
Fix new forward taint analysis
buenaventure Mar 31, 2022
313fd9a
Fix scalariformat and other compile errors
buenaventure Mar 31, 2022
75be229
Refactor: Move old code to .old, remove New prefix
buenaventure Apr 1, 2022
847baa5
First native flows working
buenaventure Apr 1, 2022
7d47c14
Fix native flows
buenaventure Apr 13, 2022
5e9cfaf
Cleanup
buenaventure May 6, 2022
16a99ae
Include llvm dependency using special sbt plugin
buenaventure May 6, 2022
89c1ff7
Fix sbt assembly
buenaventure May 11, 2022
89b91ca
Reverst scalastyle change
buenaventure May 11, 2022
91bae7d
Improve test case
buenaventure Jun 8, 2022
ed4ee71
Fix test
buenaventure Jun 9, 2022
626cce9
Fix wrong flow by adding successor to return flow and checking for ab…
buenaventure Jun 9, 2022
f34443b
Fix return flow of native code
buenaventure Jun 9, 2022
7284093
Format
buenaventure Jun 9, 2022
ab242a9
Add native to java calls to TaintTest
buenaventure Jun 16, 2022
c53aa61
Fix crashes and old tests
buenaventure Jun 17, 2022
943d7a1
Add debugData for ifds; Add simple GetElementPointer handling
buenaventure Jun 18, 2022
cb0be34
Native to Java calls WIP
buenaventure Jun 19, 2022
d3ab854
Small fixes
buenaventure Jun 22, 2022
b6a2202
JNI call analysis WIP
buenaventure Jun 25, 2022
e5d34a1
JNI call analysis WIP
buenaventure Jun 26, 2022
ec8c05a
Merge remote-tracking branch 'upstream/develop' into llvm_xlang_ifds
buenaventure Jun 30, 2022
ad65890
Fix most errors after merge
buenaventure Jun 30, 2022
c050890
Fix remaining errors after merge
buenaventure Jul 1, 2022
655d22a
Implement VTA in new IFDS for evaluation
buenaventure Jul 2, 2022
b844920
Implement Subsuming and add to evaluation
buenaventure Jul 2, 2022
d43fb11
x-lang working in simple case
buenaventure Jul 2, 2022
630162d
Bump javacpp version to work on M1 Macs.
Oct 4, 2022
52ac95c
Merge branch 'develop' into llvm_xlang_ifds
Oct 4, 2022
9786859
Remove old stuff, which should be superseded
Oct 4, 2022
91e92fa
Readd some not so obsolete Files and adapt to new IFDS Analysis
TorunR Oct 7, 2022
2d38159
Narfi ... fix Scala3 Syntax
TorunR Oct 7, 2022
4c93757
Autoformat and another backward hiccup
TorunR Oct 7, 2022
f67b853
Fix 2 small errors in llvm analysis
TorunR Oct 7, 2022
f766abb
Fix 2 other cases of scala 3 syntax.
TorunR Oct 7, 2022
55fea42
Move IFDS to si
TorunR Oct 11, 2022
42fa220
Add a language agnostic Metaproject
TorunR Oct 26, 2022
3848594
Merge branch 'develop' into feature/metaproject
TorunR Oct 27, 2022
7800e6f
Migrate TAC & AI to MetaProject
TorunR Oct 27, 2022
942f1ef
Adapt the other sub projects
TorunR Oct 28, 2022
9399a51
Fix Validate
TorunR Oct 28, 2022
e730d83
Merge branch 'develop' into feature/metaproject
TorunR Nov 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement LLVM Argument, Type(s); Better Function/Instruction represe…
…ntation
  • Loading branch information
buenaventure committed Mar 18, 2022
commit 6df8fab8dd696ff9ea7a7bff7c4e9acd220a7e0c
11 changes: 11 additions & 0 deletions OPAL/ll/src/main/scala/org/opalj/ll/llvm/Argument.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* BSD 2-Clause License - see OPAL/LICENSE for details. */
package org.opalj.ll.llvm

import org.bytedeco.llvm.LLVM.LLVMValueRef
import org.bytedeco.llvm.global.LLVM.{LLVMArgumentValueKind, LLVMGetParamParent, LLVMGetValueKind}

case class Argument(ref: LLVMValueRef) extends Value(ref) {
assert(LLVMGetValueKind(ref) == LLVMArgumentValueKind, "ref has to be an argument")

def parent(): Function = Function(LLVMGetParamParent(ref))
}
27 changes: 18 additions & 9 deletions OPAL/ll/src/main/scala/org/opalj/ll/llvm/Function.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
package org.opalj.ll.llvm

import org.bytedeco.llvm.LLVM.{LLVMBasicBlockRef, LLVMValueRef}
import org.bytedeco.llvm.global.LLVM.{
LLVMFunctionValueKind,
LLVMGetEntryBasicBlock,
LLVMGetFirstBasicBlock,
LLVMGetNextBasicBlock,
LLVMGetValueKind,
LLVMViewFunctionCFG,
LLVMViewFunctionCFGOnly
}
import org.bytedeco.llvm.global.LLVM.{LLVMFunctionValueKind, LLVMGetEntryBasicBlock, LLVMGetFirstBasicBlock, LLVMGetFirstParam, LLVMGetNextBasicBlock, LLVMGetNextParam, LLVMGetValueKind, LLVMViewFunctionCFG, LLVMViewFunctionCFGOnly}
import org.opalj.io.writeAndOpen

case class Function(ref: LLVMValueRef) extends Value(ref) {
Expand All @@ -20,6 +12,10 @@ case class Function(ref: LLVMValueRef) extends Value(ref) {
new BasicBlockIterator(LLVMGetFirstBasicBlock(ref))
}

def arguments(): ArgumentIterator = {
new ArgumentIterator(LLVMGetFirstParam(ref))
}

def entryBlock(): BasicBlock = {
BasicBlock(LLVMGetEntryBasicBlock(ref))
}
Expand All @@ -38,6 +34,9 @@ case class Function(ref: LLVMValueRef) extends Value(ref) {
}
}

override def toString: String = {
s"Function(${name()}(${arguments.map(_.typ().repr()).mkString(", ")}))"
}
}

class BasicBlockIterator(var ref: LLVMBasicBlockRef) extends Iterator[BasicBlock] {
Expand All @@ -49,3 +48,13 @@ class BasicBlockIterator(var ref: LLVMBasicBlockRef) extends Iterator[BasicBlock
basicBlock
}
}

class ArgumentIterator(var ref: LLVMValueRef) extends Iterator[Argument] {
override def hasNext: Boolean = ref != null

override def next(): Argument = {
val argument = Argument(ref)
this.ref = LLVMGetNextParam(ref)
argument
}
}
4 changes: 4 additions & 0 deletions OPAL/ll/src/main/scala/org/opalj/ll/llvm/Instruction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ sealed abstract class Instruction(ref: LLVMValueRef) extends Value(ref) {
def parent(): BasicBlock = BasicBlock(LLVMGetInstructionParent(ref))
def function(): Function = parent.parent
def next(): Option[Instruction] = OptionalInstruction(LLVMGetNextInstruction(ref))

/*def successors(): Seq[Instruction] = next match {
case Some(successor) ⇒ Seq(successor)
case None ⇒ Seq()
}*/
override def toString: String = {
s"${this.getClass.getSimpleName}(${repr()})"
}
}

case class Ret(ref: LLVMValueRef) extends Instruction(ref) with Terminator
Expand Down
84 changes: 84 additions & 0 deletions OPAL/ll/src/main/scala/org/opalj/ll/llvm/Type.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* BSD 2-Clause License - see OPAL/LICENSE for details. */
package org.opalj.ll.llvm

import org.bytedeco.llvm.LLVM.LLVMTypeRef
import org.bytedeco.llvm.global.LLVM._

object Type {
def apply(ref: LLVMTypeRef): Type = {
LLVMGetTypeKind(ref) match {
case LLVMVoidTypeKind ⇒ VoidType(ref)
case LLVMHalfTypeKind ⇒ HalfType(ref)
case LLVMFloatTypeKind ⇒ FloatType(ref)
case LLVMDoubleTypeKind ⇒ DoubleType(ref)
case LLVMX86_FP80TypeKind ⇒ X86_FP80Type(ref)
case LLVMFP128TypeKind ⇒ FP128Type(ref)
case LLVMPPC_FP128TypeKind ⇒ PPC_FP128Type(ref)
case LLVMLabelTypeKind ⇒ LabelType(ref)
case LLVMIntegerTypeKind ⇒ IntegerType(ref)
case LLVMFunctionTypeKind ⇒ FunctionType(ref)
case LLVMStructTypeKind ⇒ StructType(ref)
case LLVMArrayTypeKind ⇒ ArrayType(ref)
case LLVMPointerTypeKind ⇒ PointerType(ref)
case LLVMVectorTypeKind ⇒ VectorType(ref)
case LLVMMetadataTypeKind ⇒ MetadataType(ref)
case LLVMX86_MMXTypeKind ⇒ X86_MMXType(ref)
case LLVMTokenTypeKind ⇒ TokenType(ref)
case LLVMScalableVectorTypeKind ⇒ ScalableVectorType(ref)
case LLVMBFloatTypeKind ⇒ FloatType(ref)
case typeKind ⇒ throw new IllegalArgumentException("unknown type kind: "+typeKind)
}
}
}

sealed abstract class Type(ref: LLVMTypeRef) {
def repr(): String = {
val bytePointer = LLVMPrintTypeToString(ref)
val string = bytePointer.getString
LLVMDisposeMessage(bytePointer)
string
}

override def toString: String = s"Type(${repr()})"
}

/** type with no size */
case class VoidType(ref: LLVMTypeRef) extends Type(ref)
/** 16 bit floating point type */
case class HalfType(ref: LLVMTypeRef) extends Type(ref)
/** 32 bit floating point type */
case class FloatType(ref: LLVMTypeRef) extends Type(ref)
/** 64 bit floating point type */
case class DoubleType(ref: LLVMTypeRef) extends Type(ref)
/** 80 bit floating point type (X87) */
case class X86_FP80Type(ref: LLVMTypeRef) extends Type(ref)
/** 128 bit floating point type (112-bit mantissa) */
case class FP128Type(ref: LLVMTypeRef) extends Type(ref)
/** 128 bit floating point type (two 64-bits) */
case class PPC_FP128Type(ref: LLVMTypeRef) extends Type(ref)
/** Labels */
case class LabelType(ref: LLVMTypeRef) extends Type(ref)
/** Arbitrary bit width integers */
case class IntegerType(ref: LLVMTypeRef) extends Type(ref)
/** Functions */
case class FunctionType(ref: LLVMTypeRef) extends Type(ref) {
def returnType(): Type = Type(LLVMGetReturnType(ref))
}
/** Structures */
case class StructType(ref: LLVMTypeRef) extends Type(ref)
/** Arrays */
case class ArrayType(ref: LLVMTypeRef) extends Type(ref)
/** Pointers */
case class PointerType(ref: LLVMTypeRef) extends Type(ref)
/** Fixed width SIMD vector type */
case class VectorType(ref: LLVMTypeRef) extends Type(ref)
/** Metadata */
case class MetadataType(ref: LLVMTypeRef) extends Type(ref)
/** X86 MMX */
case class X86_MMXType(ref: LLVMTypeRef) extends Type(ref)
/** Tokens */
case class TokenType(ref: LLVMTypeRef) extends Type(ref)
/** Scalable SIMD vector type */
case class ScalableVectorType(ref: LLVMTypeRef) extends Type(ref)
/** 16 bit brain floating point type */
case class BFloatType(ref: LLVMTypeRef) extends Type(ref)
2 changes: 2 additions & 0 deletions OPAL/ll/src/main/scala/org/opalj/ll/llvm/Value.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Value(ref: LLVMValueRef) extends OptionalValue {
def name(): String = {
LLVMGetValueName(ref).getString
}

def typ(): Type = Type(LLVMTypeOf(ref))
}

case class NullValue() extends OptionalValue
Expand Down