不要编程语言编译器首先转换到组装或直接到机器code? [英] Do programming language compilers first translate to assembly or directly to machine code?

查看:173
本文介绍了不要编程语言编译器首先转换到组装或直接到机器code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在流行和广泛使用的编译器,如gcc感兴趣。但如果事情用不同的编译器做不同,我想知道这一点。

I'm primarily interested in popular and widely used compilers, such as gcc. But if things are done differently with different compilers, I'd like to know that, too.

以GCC为例,它编译C语言编写直接到短节目的的code,或者它首先将其转换为人类可读的组装,然后才使用一个(内置?)汇编的汇编程序翻译成二进制的的code - ?一系列指令到CPU

Taking gcc as an example, does it compile a short program written in C directly to machine code, or does it first translate it to human-readable assembly, and only then uses an (in-built?) assembler to translate the assembly program into binary, machine code -- a series of instructions to the CPU?

时使用汇编code创建一个二进制可执行文件显著昂贵的操作?或者是一个相对简单和快速的事是什么?

Is using assembly code to create a binary executable a significantly expensive operation? Or is it a relatively simple and quick thing to do?

(假设我们正在处理的只有x86系列处理器,以及所有的程序都为Linux编写的。)

(Let's assume we're dealing with only the x86 family of processors, and all programs are written for Linux.)

我会任何帮助非常感谢,认为这事。谢谢!

I'd be very grateful for any help and thought on the matter. Thank you!

推荐答案

GCC实际上产生的汇编和使用的汇编组装它。并非所有的编译器做到这一点 - 在MS编译器生成目标code直接,但你可以让他们产生汇编输出。翻译汇编对象code是pretty简单的过程,至少编译比较。

gcc actually produces assembler and assembles it using the as assembler. Not all compilers do this - the MS compilers produce object code directly, though you can make them generate assembler output. Translating assembler to object code is a pretty simple process, at least compared with compilation.

一些编译器产生其它高级语言code作为它们的输出 - 例如, Cfront的,产生了C作为其输出的第一个C ++编译器将其用一个C编译器编译

Some compilers produce other high-level language code as their output - for example, cfront, the first C++ compiler produced C as its output which was then compiled by a C compiler.

请注意,无论是直接编译或组装实际产生的可执行文件。这是通过在连接,这需要由编译/组件产生的各种对象code文件,解决了它们包含的所有的名字,并产生最终的可执行的二进制完成。

Note that neither direct compilation or assembly actually produce an executable. That is done by the linker, which takes the various object code files produced by compilation/assembly, resolves all the names they contain and produces the final executable binary.

这篇关于不要编程语言编译器首先转换到组装或直接到机器code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆