航空学报 > 2021, Vol. 42 Issue (9): 325177-325177   doi: 10.7527/S1000-6893.2021.25177

嵌入式处理器P2020机器码程序到C语言源程序的溯源方法

谢文光1, 李琪3, 马春燕3, 汪克念1, 尹伟2, 张涛3   

  1. 1. 中国民航大学 适航学院 民航航空器适航审定技术重点实验室, 天津 300300;
    2. 航空工业无线电电子研究所, 上海 200241;
    3. 西北工业大学 软件学院, 西安 710072
  • 收稿日期:2020-12-29 修回日期:2021-01-31 发布日期:2021-04-21
  • 通讯作者: 马春燕 E-mail:machunyan@nwpu.edu.cn
  • 基金资助:
    国家自然科学基金(61601468);航空科学基金(20185853038,2015ZD53055)

Tracing method from embedded processor P2020 machine code program to C language source program

XIE Wenguang1, LI Qi3, MA Chunyan3, WANG Kenian1, YIN Wei2, ZHANG Tao3   

  1. 1. Key Laboratory of Civil Aircraft Airworthiness Technology, College of Airworthiness, Civil Aviation University of China, Tianjin 300300, China;
    2. AVIC Radio Electronics Research Institute, Shanghai 200241, China;
    3. School of Software, Northwestern Polytechnical University, Xi'an 710072, China
  • Received:2020-12-29 Revised:2021-01-31 Published:2021-04-21
  • Supported by:
    National Natural Science Foundation of China (61601468); Aeronautical Science Foundation of China (20185853038,2015ZD53055)

摘要: 处理器PowerPC P2020在航空航天等嵌入式领域被广泛应用,以RTCA/DO-178C中A级软件的适航要求作为研究的出发点,提出了从文件、函数声明、函数体代码3层次实现P2020机器码程序到C源程序的溯源方法。在获取C语言源程序与PowerPC P2020机器码程序文件名列表的基础上,实现PowerPC P2020机器码文件主名的溯源;通过遍历C源程序抽象语法树和PowerPC P2020机器码获取函数名列表,实现PowerPC P2020机器码函数声明的溯源;通过定义C语言程序抽象语法树节点生成期望汇编指令序列的规则,实现PowerPC P2020机器码函数体的溯源。通过设计245个C源程序文件与345个PowerPC P2020机器码程序文件,1 111个C语言函数声明与1 273个PowerPC P2020机器码函数声明,以及覆盖C语言程序23类语法结构的460个测试用例,验证了PowerPC P2020机器码程序到C源程序的自动化溯源方法的有效性。结果表明:文件溯源和函数声明溯源的追溯匹配率达100%,程序函数体代码的平均溯源匹配率达97.22%。溯源匹配结果可以检查PowerPC P2020机器码程序是否在编译过程插入例外异常代码,以防止其带来的安全隐患,保证航空航天嵌入式安全关键软件机器码的安全性和可靠性。

关键词: P2020机器码程序, C语言源程序, 溯源, 源代码分析, 编译器验证

Abstract: The processor PowerPC P2020 is widely used in aeronautical embedded systems. To satisfy the airworthiness requirements of the A-level software in RTCA/DO-178C, a method of tracing from the PowerPC P2020 machine code program to the C language source program is proposed on three levels of codes:file, function declaration, and function body. On the basis of obtaining the C language source and the PowerPC P2020 machine code program file name list, the traceability of the PowerPC P2020 machine code file name is realized. By traverse the C source program abstract syntax tree and PowerPC P2020 machine code to get the list of function names, traceability of the PowerPC P2020 machine code function declaration is realized. By defining the abstract syntax tree node of the C language program to generate the expected assembly instruction sequence rules, traceability of the PowerPC P2020 machine code function body is realized. By designing 245 C language source program files and 345 PowerPC P2020 machine code program files, 1 111 C language function declarations and 1 273 PowerPC P2020 machine code function declarations, as well as 460 test cases covering 23 types of syntax structures of C language programs, effectiveness of the automatic tracing method from the PowerPC P2020 machine code program to the C language source program is verified. The results show that the traceability matching rate of document traceability and function declaration traceability reaches 100%, and the average traceability matching rate of the PowerPC P2020 function body and the C language source program function body code reaches 97.22%. The traceability matching results can check whether exception codes are inserted into the P2020 machine code program during the compilation process, so as to prevent potential safety hazards and ensure the safety and reliability of the embedded safety critical software object codes used in aerospace.

Key words: P2020 machine code, C language source program, tracing, source code analysis, compiler validation

中图分类号: