编译和 ABI 有何关系?
编译和 ABI 有何关系?
编译器的唯一工作就是构建操作系统和/或其他应用程序的应用程序二进制接口(ABI)吗?
关于ABI,引用自Wikipedia:
ABI 涵盖数据类型、 尺寸和对齐方式;召唤 约定,它控制如何 函数的参数被传递并且 返回检索到的值;系统 电话号码以及如何申请 应该进行系统调用 操作系统;如果是 完整的操作系统 ABI, 目标文件、程序的二进制格式 图书馆等。
谢谢和问候!
How are compilation and ABI related?
Is a compiler's solely job to build Application Binary Interface (ABI) to OS and/or other applications?
About ABI, quoted from Wikipedia:
ABIs cover details such as data type,
size, and alignment; the calling
convention, which controls how
functions' arguments are passed and
return values retrieved; the system
call numbers and how an application
should make system calls to the
operating system; and in the case of a
complete operating system ABI, the
binary format of object files, program
libraries and so on.
Thanks and regards!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ABI 描述了底层操作系统的功能,并包括一些有关如何编译程序的规则。编译器的工作不是“构建”ABI,而是在创建可执行代码时符合 ABI。
An ABI describes the features of the underlying OS, and includes some rules about how a program must be compiled. It's the compiler's job not to "build" the ABI, but to conform to the ABI as it creates executable code.
嗯,编译器可能不完全遵循 ABI。它必须发出有效的机器代码,但例如它可能不遵循内部函数调用的调用约定。但当然,在编译代码和操作系统之间的边界上,编译器应该遵循 ABI。
Well, compiler may not follow the ABI completely. It had to emit valid machine code but for example it may not follow calling conventions for inner function calls. But of course, on the border between compiled code and OS the compiler should follow ABI.
编译器必须从源文件输出目标文件。这取决于架构,例如寻址模式可用性、可用寄存器等,这些都在 ABI 中阐明。此外,出于性能原因,操作系统与体系结构紧密耦合,因此除非您正在编写固件,否则操作系统的系统调用调用约定以及任何此类相关细节都是 ABI 包的一部分。
编译器用机器级操作码和数据替换高级源文本。输出需要符合工具链的要求。例如,针对 Windows 的链接器将需要 PE 格式的目标文件来支持 Windows 库,如果工具链中的编译器输出为 ELF 等其他格式之一,则还需要其他格式。
Compiler has to output object file from source. This is dependent on the architecture, such as addressing mode availability, registers available, and such that are clarified within ABI. Also, OS is tightly coupled with architecture for performance reasons, so unless you are writing firmware, OS's calling convention for system calls and any such relevant details are part of ABI parcel.
Compiler replaces high-level source text by machine level opcodes and data. The output is required to comply depending on the tool-chain. For instance, linker targeting Windows will require object file in PE format for supporting Windows libraries, and additional formats if the compiler in the tool-chain output to one of these other formats like ELF.