什么是德尔福 DCU 文件? [英] What is a Delphi DCU file?

查看:17
本文介绍了什么是德尔福 DCU 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是 Delphi DCU 文件?

What is a Delphi DCU file?

我相信它代表Delphi Compiled Unit".我是否正确假设它包含目标代码,因此对应于从 C/C++ 源代码文件编译的.o"文件?

I believe it stands for "Delphi Compiled Unit". Am I correct in assuming it contains object code, and therefore corresponds to an ".o" file compiled from a C/C++ source code file?

推荐答案

我相信 .dcu 通常意味着Delphi 编译单元",而不是 .pas 文件,它只是Pascal 源代码".

I believe .dcu generally means "Delphi Compiled Unit" as opposed to a .pas file which is simply "Pascal source code".

.dcu 文件是 DCC 编译器编译 .pas 文件后生成的文件(.dfm 文件转换为二进制资源,然后由链接器直接处理).

A .dcu file is the file that the DCC compiler produces after compiling the .pas files (.dfm files are converted to binary resources, then directly processed by the linker).

它类似于 .o.obj 其他编译器生成的文件,但包含有关符号的更多信息(因此您可以 从中逆向工程单元的接口部分 省略注释和编译器指令).

It's analogous to .o and .obj files that other compilers produce, but contains more information on the symbols (therefore you can reverse engineer the interface section of a unit from it omitting comments and compiler directives).

.dcu 文件在技术上不是缓存"文件,尽管如果您不删除它们并且何时不需要重新编译它们,您的构建会运行得更快..dcu 文件与生成它的编译器版本相关联.从这个意义上说,它不如 .o 或 .obj 文件可移植(尽管它们也存在兼容性问题)

A .dcu file technically not a "cache" file, although your builds will run faster if you don't delete them and when doesn't need to recompile them. A .dcu file is tied to the compiler version that generated it. In that sense it is less portable than .o or .obj files (though they have their share of compatibility problems too)

传统上,编译器会将源代码语言翻译成某种中间形式.解释器不会这样做——他们只是直接解释语言并立即运行应用程序.BASIC 是解释型语言的典型例子.DOS 和 Windows 中的命令行"有一种语言,可以写入名为批处理文件" 带有 .bat 扩展名.但是在命令行上输入东西直接执行它们.在 *nix 环境中,有很多不同的命令行解释器(CLI),例如shcshbashksh、 等等.您可以从所有这些文件中创建批处理文件——这通常被称为脚本语言".但是现在有很多其他语言既可以解释也可以编译.

Compilers have traditionally translated source code languages into some intermediate form. Interpreters don't do that -- they just interpret the language directly and run the application right away. BASIC is the classic example of an interpreted language. The "command line" in DOS and Windows has a language that can be written in files called "batch files" with a .bat extension. But typing things on the command line executed them directly. In *nix environments, there are a bunch of different command-line interpreters (CLIs), such as sh, csh, bash, ksh, and so on. You can create batch files from all of them -- this are usually referred to as "scripting languages". But there are a lot of other languages now that are both interpreted and compiled.

无论如何Java.Net,例如,编译成所谓的中间字节码" 表示.

Anyway Java and .Net, for example, compile into something called an intermediate "byte-code" representation.

Pascal 最初是 编写为单程编译器,以及 Turbo Pascal(源自 PolyPascal) - CP/MCP/M-86DOS - 直接生成二进制可执行文件 (COM) 在这些操作系统下运行的文件.

Pascal was originally written as a single-pass compiler, and Turbo Pascal (originating from PolyPascal) - with different editions for CP/M, CP/M-86 and DOS - directly generated a binary executable (COM) file that ran under those operating systems.

Pascal 最初被设计为一种小型、高效的语言,旨在鼓励使用结构化编程和数据结构化的良好编程实践;Turbo Pascal 1 最初设计为IDE 内置非常快速的编译器,是 DOS 和 CP/M 市场上的一个负担得起的竞争对手,以应对漫长的编辑/编译/链接周期时间.Turbo Pascal 和 Pascal 与当时的任何编程环境都有类似的限制:内存和磁盘空间以千字节,以兆赫为单位的处理器速度.

Pascal was originally designed as a small, efficient language intended to encourage good programming practices using structured programming and data structuring; Turbo Pascal 1 was originally designed as a an IDE with built-in very fast compiler, and an affordable competitor in the the DOS and CP/M market against the long edit/compile/link cycles at that time. Turbo Pascal and Pascal had similar limitations as any programming environment back then: memory and disk space were measured in kilobytes, processor speeds in Megahertz.

链接到可执行二进制文件会阻止您链接到单独编译的单元和库.

Linking to an executable binary prevented you from linking to separately compiled units and libraries.

在 Turbo Pascal 之前,有 UCSD p-System 操作系统(支持多种语言,包括 Pascal.当时的 UCSD Pascal 编译器已经用单元扩展了 Pascal 语言,这些单元编译成允许将多个单元链接在一起的伪机器字节码(称为 p 代码)格式.虽然很慢,

Before Turbo Pascal, there was UCSD p-System operating system (supporting many languages, including Pascal. The UCSD Pascal compiler back then already extended the Pascal language with units) which compiled into a pseudo-machine byte-code (called p-code) format that allowed linking multiple units together. It was slow though,

与此同时,cVAXUnix 环境,并将其编译为 .o 文件,这意味着目标代码"而不是源代码".注意:这与我们今天所说的对象"完全无关.

Meanwhile, c evolved in VAX and Unix environments, and it compiled into .o files, which meant "object code" as opposed to "source code". Note: this is totally unrelated to anything we call "objects" today.

Turbo Pascal 到并包括版本 3 直接生成的 .com 二进制输出文件(尽管您可以使用修改这些覆盖文件),并且从版本 4 开始支持将代码分离成单元,这些单元首先编译成 .tpu 文件,然后链接到最终的可执行二进制文件.Turbo C 编译器生成 .obj(目标代码)文件而不是字节码,Delphi 2 引入了 .obj 文件生成以便与 C++ Builder 合作.

Turbo Pascal up to and including version 3 directly generated .com binary output files (although you could use amend those overlays files), and as of version 4 supported separating code into units that first compiled into .tpu files before linked into the final executable binary. The Turbo C compiler generated .obj (object code) files rather than byte-codes, and Delphi 2 introduced .obj file generation on order to co-operate with C++ Builder.

目标文件在每个单元内使用相对寻址,并需要所谓的修复"(或 relocation) 稍后让它们运行.修复指向预期存在于其他目标文件或库中的符号标签.

Object files use relative addressing within each unit, and require what's called "fix-ups" (or relocation) later on to make them run. Fix-ups point to symbolic labels that are expected to exist in other object files or libraries.

有两种修复":一种是通过名为链接器".链接器接收一堆目标文件并将它们拼接成类似于拼布被子的东西.然后它通过插入指向所有外部定义标签的指针来修复"所有相关引用.

There are two kinds of "fix-ups": one is done statically by a tool called a "linker". The linker takes a bunch of object files and seams them together into something analogous to a patchwork quilt. It then "fixes-up" all of the relative references by plugging-in pointers to all of the externally-defined labels.

第二次修复是在程序加载运行时动态完成的.它们是由称为加载器"的东西完成的,但您永远不会看到.当您在命令行上键入命令时,会调用 loader 来加载 EXE文件加载到内存中,根据文件的加载位置修复剩余的链接,然后将控制权转移到应用程序的入口点.

The second fix-ups are done dynamically when the program is loaded to run. They're done by something called the "loader", but you never see that. When you type a command on the command line, the loader is called to load an EXE file into memory, fix-up the remaining links based on where the file is loaded, and then control is transferred to the entry point of the application.

当 Borland 在 Turbo Pascal 中引入单位时,.dcu 文件起源于 .tpu 文件,然后随着 Delphi 的引入而改变扩展名.它们与 .obj 文件非常不同,但您可以链接到来自 Turbo Pascal 和 Delphi 的 .obj 文件.

So .dcu files originated as .tpu files when Borland introduced units in Turbo Pascal, then changed extension with the introduction of Delphi. They are very different from .obj files, though you can link to .obj files from Turbo Pascal and Delphi.

Delphi 还完全隐藏了链接器,因此您只需进行编译和运行即可.但是,所有链接器设置仍然存在于 Delphi 的选项窗格之一中.

Delphi also hid the linker entirely, so you just do a compile and a run. All of the linker settings are still there, however, in one of Delphi's options panes.

这篇关于什么是德尔福 DCU 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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