Rinaldini Julien
2012-Apr-27 12:52 UTC
[LLVMdev] RE : RE : Detect if a basicblock is part of a loop
This is my main.c (just a crappy test file):
#include <stdlib.h>
void foo() {
foo();
}
int main(int argc,char** argv) {
int a = 1;
int b = 3;
int c = a+b;
int k;
for(k=0;k<10;++k) { // The loop I'm
trying to detect
int sdf = 123123;
c++;
}
if(c - atoi(argv[1]) < 4)
c = 0;
else
c = 1;
return c;
}
The ir code corresponding to the loop:
; <label>:7 ; preds = %13, %0
%8 = load i32* %k, align 4
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %16
; <label>:10 ; preds = %7
store i32 123123, i32* %sdf, align 4
%11 = load i32* %c, align 4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %c, align 4
br label %13
; <label>:13 ; preds = %10
%14 = load i32* %k, align 4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %k, align 4
br label %7
> is LLVMobfuscationTest.so your own pass? What does it do?
Yes it's my own lib... It contains some obfuscation's passes. The one
I'm trying to make now is making code flattening!
Cheers
ps: I tried Cristianno Martins solution, but it didn't work too :(
________________________________________
De : 陳韋任 [chenwj at iis.sinica.edu.tw]
Date d'envoi : vendredi 27 avril 2012 14:45
À : Rinaldini Julien
Cc: llvmdev at cs.uiuc.edu
Objet : Re: [LLVMdev] RE : Detect if a basicblock is part of a loop
> Just as I said to Hal, nothing else than:
> $ clang -emit-llvm -S -o main.ll main.c
> $ ../build/Release/bin/opt -load
../build/Release/lib/LLVMobfuscationTest.so -flattening -S main.ll -o
main.opt.ll
Then you might need to past your main.c. Besides, is LLVMobfuscationTest.so
your own pass? What does it do?
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
> Yes it's my own lib... It contains some obfuscation's passes. The one I'm trying to make now is making code flattening!^^^^^^^^^^^^^^^^^^^^^^ What's the flattening effect? Maybe try NOT to flat it first? Regards, chenwj -- Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj
Rinaldini Julien
2012-Apr-27 13:24 UTC
[LLVMdev] RE : RE : RE : Detect if a basicblock is part of a loop
It try to put all basicblock in a switch in a loop, like that for example:
int main() {
if(something)
somethingelse:
else
another;
}
become:
int main() {
while(true) {
switch(var) {
case 0:
if(something)
var+=1;
else:
var+=2;
break;
case1:
somethingelse;
var = MAX;
break;
case2:
another;
var = MAX;
case MAX:
exit();
}
}
}
But I'm trying that before any attempt of code flattening, just to see if I
can detect loop...
Cheers
________________________________________
De : 陳韋任 [chenwj at iis.sinica.edu.tw]
Date d'envoi : vendredi 27 avril 2012 15:05
À : Rinaldini Julien
Cc: llvmdev at cs.uiuc.edu
Objet : Re: [LLVMdev] RE : RE : Detect if a basicblock is part of a loop
> Yes it's my own lib... It contains some obfuscation's passes. The
one I'm trying to make now is making code flattening!
^^^^^^^^^^^^^^^^^^^^^^
What's the flattening effect? Maybe try NOT to flat it first?
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
Possibly Parallel Threads
- [LLVMdev] RE : RE : Detect if a basicblock is part of a loop
- [LLVMdev] RE : RE : Detect if a basicblock is part of a loop
- [LLVMdev] RE : Detect if a basicblock is part of a loop
- [LLVMdev] RE : Detect if a basicblock is part of a loop
- [LLVMdev] RE : Detect if a basicblock is part of a loop