面向RISC-V的汇编程序语义等价性自动化测试系统
作者:
基金项目:

国家自然科学基金(61802427)


Automatic Testing System for Semantic Equivalence of RISC-V Assembly Programs
Author:
  • 摘要
  • | |
  • 访问统计
  • |
  • 参考文献 [17]
  • |
  • 相似文献 [20]
  • | | |
  • 文章评论
    摘要:

    本文设计并实现了一套面向RISC-V的汇编程序语义等价性自动化测试系统. 在面向RISC-V开发软件时, 尤其是基于扩展指令(例如向量指令)编写高效的程序时, 很难避免以手写汇编的方式编写代码. 例如, 为标准的C函数库编写相应的向量版函数. 与编译器自动生成的代码不同, 手写的汇编代码虽然可以最大限度地提高程序的效率, 但因绕过了编译时对程序的约束(如类型检查、寄存器分配等)而对开发者提出了更高的要求. 能否对新版本与标准版本的汇编程序进行快速地、自动化的语义等价性测试, 将大大影响代码的正确性和软件开发和调试的效率. 已有面向RISC-V的测试框架缺乏对语义等价性测试的支持, 也未考虑程序执行带来的副作用. 本研究基于模拟器的动态测试环境, 设计并实现了一套面向RISC-V的汇编程序语义等价性自动化测试系统. 系统通过跟踪机器状态, 捕获程序执行的副作用, 并结合用户定义的测试目标生成测试报告. 实验表明, 本系统相比已有的测试系统, 能够有效地对RISC-V汇编程序的语义等价性进行测试.

    Abstract:

    In this study, we design and implement an automatic testing system for semantic equivalence of RISC-V assembly programs. While developing RISC-V programs, especially developing efficient programs based on extension instructions (such as vector extension), developers often write assembly code manually. For example, for the standard C function library, we often write the corresponding vector version functions for better performance. Without the compiler, the manually developed assembly code can maximize the efficiency of the program, but it skips many important compilation processes (such as type checking and register allocation), thus putting forward higher requirements for the developers. It will greatly affect the correctness of the code and the efficiency of software development and debugging if we can quickly and automatically test whether the rewritten version is semantically equivalent to the standard version of the program. The existing RISC-V testing framework lacks support for semantic equivalence testing and fails to consider the side effects caused by program executions. Based on the dynamic test environment of a simulator, this research designs and implements an automatic testing system for semantic equivalence of RISC-V assembly programs. It can capture side effects caused by program executions through monitoring machine states and generate testing reports with user-defined testing targets. Experiments show that the system, compared with existing testing systems, can test the semantic equivalence of RISC-V assembly programs.

    参考文献
    [1] Pierce BC. Types and Programming Languages. Cambridge: The MIT Press, 2002.
    [2] Chaitin GJ. Register allocation & spilling via graph coloring. ACM SIGPLAN Notices, 1982, 17(6): 98–101. [doi: 10.1145/872726.806984
    [3] 张新华, 何永前. 软件测试方法概述. 科技视界, 2012, (4): 35–37
    [4] 单锦辉, 姜瑛, 孙萍. 软件测试研究进展. 北京大学学报(自然科学版), 2005, 41(1): 134–145. [doi: 10.3321/j.issn:0479-8023.2005.01.020
    [5] Tse AY. Software testing apparatus and method. US, 5742754. (1998-04-21).
    [6] 王戟, 詹乃军, 冯新宇, 等. 形式化方法概貌. 软件学报, 2019, 30(1): 33–61. [doi: 10.13328/j.cnki.jos.005652
    [7] King JC. Symbolic execution and program testing. Commu-nications of the ACM, 1976, 19(7): 385–394. [doi: 10.1145/360248.360252
    [8] Yan H, Sui Y, Chen SP, et al. Spatio-temporal context reduction: A pointer-analysis-based static approach for detecting use-after-free vulnerabilities. Proceedings of the 40th International Conference on Software Engineering. New York: ACM, 2018. 327–337.
    [9] Godefroid P, Levin M, Molnar D. Automated whitebox fuzz testing. Proceedings of Network and Distributed Systems Security. San Diego: Internet Society. 2011.
    [10] 谢肖飞, 李晓红, 陈翔, 等. 基于符号执行与模糊测试的混合测试方法. 软件学报, 2019, 30(10): 3071–3089. [doi: 10.13328/j.cnki.jos.005789
    [11] Lim JP, Nagarakatte S. Automatic equivalence checking for assembly implementations of cryptography libraries. 2019 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). Washington DC: IEEE, 2019. 37–49.
    [12] Bellard F. QEMU, a fast and portable dynamic translator. Proceedings of the annual conference on USENIX Annual Technical Conference. Anaheim: USENIX Association, 2005. 41.
    [13] 宋倩. 基于遗传算法的测试用例生成技术. 计算机系统应用, 2014, 23(11): 264–267. [doi: 10.3969/j.issn.1003-3254.2014.11.050
    [14] Godefroid P, Klarlund N, Sen K. DART: Directed automated random testing. Proceedings of the 2005 ACM SIGPLAN Conference on Programming Language Design and Implementation. New York: ACM, 2005. 213–223.
    [15] Chris L and Vikram A. LLVM: A compilation framework for lifelong program analysis & transformation. International Symposium on Code Generation and Optimization, 2004. CGO 2004. San Jose: IEEE, 2004. 75–86.
    [16] 陈翔, 鞠小林, 万志, 等. 基于程序频谱的动态缺陷定位方法研究. 软件学报, 2015, 26(2): 390–412. [doi: 10.13328/j.cnki.jos.004708
    [17] Wong WE, Gao RZ, Li YH, et al. A survey on software fault localization. IEEE Transactions on Software Engineering, 2016, 42(8): 707–740. [doi: 10.1109/TSE.2016.2521368
    引证文献
引用本文

徐学政,王涛,方健,张光达.面向RISC-V的汇编程序语义等价性自动化测试系统.计算机系统应用,2021,30(11):33-40

复制
分享
文章指标
  • 点击次数:1128
  • 下载次数: 2368
  • HTML阅读次数: 1397
  • 引用次数: 0
历史
  • 收稿日期:2021-04-28
  • 最后修改日期:2021-05-21
  • 在线发布日期: 2021-10-22
文章二维码
您是第11371949位访问者
版权所有:中国科学院软件研究所 京ICP备05046678号-3
地址:北京海淀区中关村南四街4号 中科院软件园区 7号楼305房间,邮政编码:100190
电话:010-62661041 传真: Email:csa (a) iscas.ac.cn
技术支持:北京勤云科技发展有限公司

京公网安备 11040202500063号