什么是目标文件包含哪些内容? [英] What does an object file contain?

查看:168
本文介绍了什么是目标文件包含哪些内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C或C ++编写的各个阶段,我知道一个目标文件获取生成(即any_name.o文件)。这是什么.o文件将包含哪些内容?因为它是一个二进制文件,我不能打开它。

During the various stages of compilation in C or C++, I know that an object file gets generated (i.e., any_name.o file). What does this .o file contain? I can't open it since it's a binary file.

有谁请帮助我吗?是目标文件的内容主要是依赖于我们在Unix上使用编译器?

Could anybody please help me? Are the contents of the object file mainly dependent on the compiler which we use on Unix?

推荐答案

目标文件可以包含一堆东西:基本上它是部分或全部下面的列表中:

Object files can contain a bunch of stuff: Basically it's some or all of the list below:


  • 符号名称

  • 编译code

  • 恒定的数据,例如。字符串

  • 进口 - 这符号编译code引用(得到由连接器固定起来)

  • 出口 - 这符号的目标文件,使可用于其他对象文件

链接器变成了一堆目标文件到可执行文件,通过匹配了所有的进口和出口,并修改编译code,所以正确的函数被调用。

The linker turns a bunch of object files into an executable, by matching up all the imports and exports, and modifying the compiled code so the correct functions get called.

这篇关于什么是目标文件包含哪些内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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