交叉编译系统的研究与实现
详细信息    本馆镜像全文|  推荐本文 |  |   获取CNKI官网全文
摘要
伴随着以计算机技术、通讯技术为主的信息技术的飞速发展和互联网的广泛应用,3C(Computer、Communication、Consumer)合一将成为必然趋势。信息家电,手持设备,移动设备等嵌入式产品的迅速发展,使得嵌入式软件开发再度成为一个研究热点。
     由于嵌入式设备的性能局限,往往不能通过本机编译得到所需软件的可执行程序。因此,以Linux为主机操作系统,搭配一个交叉编译系统,为嵌入式设备生成可执行程序已成为现在日益流行的编译嵌入式软件的解决方案。而开放源码的编译器GCC,经过多年的发展,已能支持几乎所有知名厂商的处理器,是嵌入式软件开发中理想的交叉编译器。
     但现有GCC支持的平台并不能满足层出不穷的嵌入式产品的开发需要,仍有许多平台得不到支持。本论文以交叉编译系统ZLTCG的开发为背景,详细介绍了交叉编译系统GCC的体系结构,对其高度可移植性所依赖的中间表示和机器描述技术进行深入研究,并在此基础上完成了GCC在目标机MIPSX上的移植工作。本文根据新目标机的特点,利用了指令拆分,延时槽调度,窥孔优化等技术,既实现了对新目标机的支持,又吸收了原有系统高度优化和可移植的优点。
     论文首先概述了编译系统的发展背景和原理,重点介绍了编译器系统的系统结构、自举与移植。然后介绍了交叉编译系统ZLTCG的开发背景和体系结构。第二章详细分析了编译器GCC,重点说明了GCC的设计思想,系统结构及其中间语言和机器描述文件机制。第三章介绍了交叉编译系统的移植过程,重点解释了移植的思路和方法,移植的准备工作,移植的具体步骤,实现难点及相关的一些技术细节,并给出了移植成功后的测试结果。其中移植的准备工作中详细说明了目标机MIPSX的系统结构和应用二进制接口的定义,而移植的具体步骤中详细阐述了对编译器后端的移植过程。最后是一点总结和展望。
With the rapid development of information technology including computer technology and communication technology,and with the Internet widely used,the combination of computer,communication and consumer is inevitable. For the rapid development of the embedded,handheld and wireless devices,the embedded software is becoming a hot spot of the information industry.
    Since the resource limitation of embedded equipements,developers usually can't compile software on them. It seems to be a popular solution for embedded equipements to compile software on another system,which use Linux as an operating system with a cross-compiler built on. And GCC,one of the open source compiler,which had been developed many years,can support nearly all famous processor and become an appropriate cross-compiler for the development of embedded software.
    However,GCC can't support all embedded equipements,there are still many platforms need cross-compilers. With the background of developing a renovated cross-compiler named ZLTCG supporting processor MIPSX,this thesis analyzes the architecture of GCC cross-compiler system,deeply studies the intermediate representation and machine description which the portability of GCC are based on,and realizes porting of GCC cross-compiler system to a target processor MIPSX. This thesis makes use of instruction split,delay-slot scheduling and peephole optimization in porting. The new cross-compiler system,ZLTCG,not only supports the new target but also absorbs the old system's advantages on code optimization and portability.
    At First,this thesis describes the developing history and theories of compiler,especially on its architecture,bootstrapping and porting. Then it introduces the developing background and architecture of the cross-compiler system,ZLTCG. In chapter 2,it analyses GCC in details,especially on its designatioin,architecture,intermediate language and machine description files. In chapter 3,it explains the implementation of ZLTCG,describes its ways and means,the preparation and the porting,resolves some difficult problems and explaines some technologies in detail,offers the test result. In the preparation part,it defines the architecture of MIPSX and its application binary interface. In the porting part,it describe the porting of compiler's backend. Last,it gives some conclusions and foresight.
引文
[Stal 92] Richard M Stallman, Using and Porting Gnu CC. 电子文档:http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_toc.html
    [RedDragon 86] Aho, Sethi, Ullman. Compilers: Principles, Techniques and Tools. Addison-Wesley 1986. ISBN 0-201-10194-7
    [Porting 00] Hans-Peter Nilsson. Porting GCC for Dunces. May 21, 2000
    [MIPSX 88] PAUL CHOW. MIPS-X INSTRUCTION SET and PROGRAMMER'S MANUAL. Technical Report No. CSL-86-289. MAY 1988
    [MIPSX 86] John L. Hennessy and MarkA. Horowitz. An Overview of the MIPS-X-MP Project. STANFORD UNIVERSJTY-STANFORD, CA943052192. Technical Report No. 86-300. April 1986
    [ABI 96] The Santa Cruz Operation, Inc. SYSTEM V APPLICATION BINARY INTERFACE MIPS RISC Processor Supplement. 3rd Edition. February 1996
    [Levine] John R. Levine. Linkers & Loaders, Revision: 2.2.
    [SPIM] James R. Larus. SPIM S20: A MIPS R2000 Simulator.
    [Hennessy] John Hennessy and David Patterson, Computer Architecture A Quantitative Approach, Second Edition.
    [石教英] 石教英等编。《计算机体系结构》 浙江大学出版社出版。ISBN 7-308-02055-X/TP.175
    [冯博琴] 冯博琴、冯岗(西安交通大学)等译。《编译原理及实践》 英文书名:COMPILER CONSTRUCTION: PRINCIPLE AND PRACTICE原著作者:Kenneth C. Louden, ISBN: 7-111-07703-2
    [ISO C 90] Programming languages-C, International Standard. ISO/IEC 9899, First edition, 1990-12-15.
    [K&R 88] Kernighan, Richie. The C Programming Language, Second Edition. Prentice-Hall 1988. ISBN 0-13-110362-8
    [Holub] Allen I. Holub. Compiler Design in C.
    [Dragon] A. Silberschatz, P. Galvin, and G. Gagne, Operating System Concepts
    
    
    [Stallings] William Stallings, Operating Systems: Internals and Design Principles 3rded
    [任珊红96] GCC在平台模型MODE上的移植 (Porting GCC on the Platform Model MODE)。任珊红,赵雄芳。计算机工程与科学(期刊)。第19卷,第3期,p81-85。
    [McFarling 91] McFarling. Procedure Merging with Instruction Cache[C]. Proceedings of the ACM SIGPLAN' 91 Conference on Programming Language Design and Implementation, Toronto, Onraria, June, 1991, 71-79.
    [Aho 89] Alfred V Aho, Mahadevan Ganapathi, Steven W K Tjiang. Code Generation Using Tree Matching and Dynamic Programming[J]. ACM Transactions on Programming Languages and Systems, 1989, 11(4):491-516.
    [Aho 86] Alfred V Aho, Ravi Sethi, Jeffrey D Ullman. Compiler Principles, Techniques, and Tools[Z]. 1986.
    [Aho 76] Alfred V Aho, Steven C Jonson. Optional Code Generation for Expression Trees[J]. Journal of the ACM, 1976, 23(3): 458-501.
    [Linux 99] 李善平、郑扣根。Linux系统分析及实验教程。机械工业出版社.1999/9
    [Storer 82] Storer J A, Szymanske T G. Data Compression via Textural Substitution[j]. Journal of the ACM, 1982, 29(4).
    [嵌入式应用] www.ccidnet.com/tech/os/2001/O8/23/58_3080.html
    [Linux doc] Linux系统电子文档:http://www.linuxdoc.org/
    [孙永杰] 孙永杰。“引人注目的嵌入式Linux”。微电脑世界,2000年第49期