arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2403.12973cs.PLcs.CL
收藏

C Analyzer:一个用于C程序的静态程序分析工具

C Analyzer : A Static Program Analysis Tool for C Programs

INDIAN INSTITUTE OF TECHNOLOGY, BOMBAY(印度理工学院孟买分校)

Rajendra Kumar Solanki

AI总结:

本文提出C Analyzer,一个基于抽象解释技术的C程序静态分析工具,利用LLVM Clang API和CIL转换,支持多种抽象域以检测除零、溢出等运行时错误。

摘要:

当今世界日益依赖软件程序,编写无错误且正确的程序至关重要。基于形式化方法的程序验证可以通过检测安全关键系统中的运行时错误来保证这一点,从而避免对人类生命可能产生的不利影响,并节省时间和金钱。本项目工作试图利用抽象解释技术对C程序进行静态分析。C Analyzer是为C程序静态分析而开发的工具。C Analyzer的这一实现提供了一种即插即用域架构,可供多个抽象域使用。C Analyzer支持四个抽象域——Interval、Octagon、Polyhedra和Bit Vector。我们使用这些不同的域来获得程序验证所需的精度。C Analyzer工具使用LLVM C/C++编译器前端Clang API来生成并遍历给定C程序的控制流图(CFG)。该工具在CFG遍历期间,为CFG基本块中的语句生成不同抽象域的不变量。利用这些不变量,可以分析程序的一些属性,例如除以零、模零、算术溢出等。我们还使用源到源转换工具CIL(Common Intermediate language)将一些C构造转换为更简单的构造,例如将逻辑运算符、switch语句和条件运算符转换为if-else阶梯,并将do-while和for循环转换为while循环。使用C Analyzer,可以分析C程序构造,例如声明、赋值、二元运算(算术、关系、按位移位等)、条件(if-else)、循环(while、do while、for循环)、嵌套条件和嵌套循环。目前,该工具不支持数组、结构、联合、指针或函数调用。

英文摘要:

In our times, when the world is increasingly becoming more dependent on software programs, writing bug-free, correct programs is crucial. Program verification based on formal methods can guarantee this by detecting run-time errors in safety-critical systems to avoid possible adverse impacts on human life and save time and money. This project work tries to leverage Abstract Interpretation techniques for static analysis of C programs. C Analyzer is a tool developed for static analysis of C programs. This implementation of C Analyzer provides a plug-and-play domain architecture for multiple abstract domains to be used. C Analyzer supports four abstract domains - Interval, Octagon, Polyhedra, and Bit Vector. We use these different domains for required precision in program verification. C Analyzer tool uses LLVM C/C++ compiler frontend Clang API to generate and traverse the Control Flow Graph (CFG) of a given C program. This tool generates invariants in different abstract domains for statements in basic blocks of CFG during CFG traversal. Using these invariants, some properties of a program, such as dividing by zero, modulus zero, arithmetic overflow, etc., can be analyzed. We also use a source-to-source transformation tool, CIL (Common Intermediate language), to transform some C constructs into simpler constructs, such as transforming logical operators, switch statements, and conditional operators into if-else ladders and transforming do-while and for loops into while loops. Using C Analyzer, C program constructs such as declarations, assignments, binary operations (arithmetic, relational, bitwise shift, etc.), conditions (if-else), loops (while, do while, for loop), nested conditions, and nested loops can be analyzed. Currently, this tool does not support arrays, structures, unions, pointers, or function calls.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑