在上一小节,通过以下四条命令,我们有意地给ucc传递不同的参数来依次调用预处理器、编译器、汇编器和连接器。当然实际使用ucc命令时,我们不会绕这么大一个圈子,直接用”ucc hello .c -o hello”即可得到可执行程序hello。
iron@ubuntu:demo$ ucc -E hello.c -o hello.i
iron@ubuntu:demo$ ucc --dump-ast --dump-IR -S hello.i -o hello.s
iron@ubuntu:demo$ ucc -c hello.s -o hello.o
iron@ubuntu:demo$ ucc hello.o -o hello
这一小节,我们进入目录ucc\driver来分析一下ucc驱动器的源代码。图1.17给出了ucc\driver\linux.c中的部分代码。第17至22行是我们使用” ucc -E hello.c -o hello.i”命令时,ucc驱动

本文详细介绍了UCC编译器的驱动程序,通过分析uccdriverlinux.c的部分代码,揭示了预处理器、C编译器、汇编器和连接器的实际调用过程。通过fork()、execv()和wait()系统调用创建和执行子进程,实现编译工具链的功能。同时,解析了命令行参数如何与预定义命令模板结合,生成执行命令。
最低0.47元/天 解锁文章
4422

被折叠的 条评论
为什么被折叠?



