mchalupa / dg

[LLVM Static Slicer] Various program analyses, construction of dependence graphs and program slicing of LLVM bitcode.
MIT License
474 stars 131 forks source link

Only function declaration #362

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello, Sometimes the result of slicing is not an executable program. It removes the definitions of some functions and turns them into declarations, leaving only callsite. These functions are not slicing criterion. So I cannot compile this sliced bc file. The linker says that there is a undefined function. Is it a bug? How to deal with such a problem? Looking forward to your reply. Thanks!

mchalupa commented 3 years ago

Hi, do you have any concrete examples?

Thanks

ghost commented 3 years ago

cjson_.ll.zip This is the [cjson project] IR file generated by wllvm and it is executable. For example , I want to slice for free function.

llvm-slicer -c free cjson_.ll 
...  
...
[llvm-slicer] Sliced away 586 from 3303 nodes in DG  
[llvm-slicer] saving sliced module to: cjson_.ll.sliced

Then I llvm-dis the sliced file and compile it.

/usr/bin/ld: /tmp/cjson_-8c1b09.o: in function `cJSON_Duplicate':
llvm-link:(.text+0x3173): undefined reference to `cJSON_Delete'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

when I slice for printf function

llvm-slicer -c printf cjson_.ll 
...
[llvm-slicer] Sliced away 586 from 3303 nodes in DG
[llvm-slicer] saving sliced module to: cjson_.ll.sliced

I get the same result like above. And it is strange that llvm-slicer sliced away the same number(586) of nodes. I donot know why. Can you help me? Thanks.

mchalupa commented 3 years ago

Do the dg in devel-1118 branch works for you?

ghost commented 3 years ago

It works ! Thank you.