所有语言的通用链接器
给定 ISA 的各种语言的目标代码是否有一个通用的链接器?或者是各种语言需要针对底层平台的单独链接器?我理解链接器是一个系统软件,应该是所有人通用的?
Is a linker common to the object codes of various languages for a given ISA? or is it that various languages need separate linker for an underlying platform? I understand linker to be a system software and should be common to all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要了解链接器链接目标代码。该目标代码是特定于机器(通常是操作系统)的。有几种不同的标准目标代码格式。链接器无法链接来自不同机器体系结构的目标代码。即使它可以做到这一点,它也不会执行。话虽如此,只要编译器在同一台机器上运行,有时甚至在同一操作系统上运行,您几乎总是可以链接来自不同语言的目标代码。例如,如果您用 C 创建一个程序并希望将其链接到 Pascal 目标文件,这通常会起作用。最流行的目标代码格式称为 COFF 目标代码。 COFF 代码几乎是普遍接受的目标代码标准格式。无论您使用哪种语言编译器来生成代码(只要它来自相同的机器体系结构),大多数链接器都会理解能够链接 COFF 文件。
First you need to understand that the linker links object code. This object code is machine (and usually operating system) specific. There are several different standard object code formats. A linker can not link object code from different machine architectures. And even if it could do that, it wouldn't execute. That being said, you can almost always link object code from different languages as long as the compilers run on the same machine and sometimes even the same operating system. For example, if you create a program in C and want to link with it a Pascal object file, this will usually work. The most popular object code format is called COFF object code. COFF code is almost universally the accepted standard format for object code. It doesn't matter what language compiler you use to generate the code (as long as its from the same machine architecture), most linkers will understand be able to link COFF files.