可以读取目标文件吗?

发布于 2024-12-22 13:23:29 字数 141 浏览 5 评论 0原文

我对 .obj 文件很好奇:我几乎不知道它们是什么(或者它们包含什么),所以我用 Vim 文本编辑器打开它们,我在里面发现了一种类似外星人的语言...

有什么方法可以理解它们代表什么以及它们的内容是什么 另外,它们的用途是什么?

I was curious about .obj files: I pretty much don't know what they are (or what they contain), so I opened them with Vim text editor and what I found inside was an Alien like language...

Is there any way to understand what they represent and what is their content
Also, for what are they being used?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

月隐月明月朦胧 2024-12-29 13:23:29

当然。

但每个不同的平台都有不同的对象格式。在 Windows 上,您可以使用 dumpbin 之类的工具(dumpbin 随 Visual工作室)。在 Linux 上,您可以使用“dumpobj”,或反汇编程序。

这里有一个很好的 Linux 链接:

http://www.linuxjournal.com/article/1060

PS :
objdump 还可以让您反汇编对象。就像您过去能够在 DOS PC 上进行“调试”一样......

Sure.

But every different platform has a different object format. On Windows, you could use a tool like dumpbin (dumpbin comes with Visual Studio). On Linux, you could use "dumpobj", or disassemble the program.

Here's a good link for Linux:

http://www.linuxjournal.com/article/1060

PS:
objdump also lets you disassemble the object. Like you used to be able to do with "debug" on DOS PCs...

去了角落 2024-12-29 13:23:29

link.exe 使用的 .obj 文件具有 MS COFF 格式。

您可以此处找到“Microsoft PE 和 COFF 规范”,并解析 < code>.obj 文件根据它。

或者,您可以使用现有工具,例如 dumpbin

The .obj files used by link.exe has MS COFF format.

You can find "Microsoft PE and COFF Specification" here, and parse .obj file according to it.

Or, you can use existing tool like dumpbin.

著墨染雨君画夕 2024-12-29 13:23:29

readelf 工具擅长向您展示一些数据细节:

$ readelf -a /usr/bin/readelf
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
...

它检查可执行文件特定部分的一些能力也可以派上用场:

$ readelf -p .rodata /usr/bin/readelf | more

String dump of section '.rodata':
  [     4]  R_IA64_IMM14
  [    11]  R_IA64_NONE
  ...
  [  1f58]    Personality routine: 
  [  1f70]  __gcc_personality_v0
  [  1f85]  __gxx_personality_v0
  [  1f9a]  __gcj_personality_v0
  [  1faf]  __gnu_objc_personality_v0
  ...

实际上反汇编代码有点困难;如果你用-g编译代码来调试符号,你可以使用readelf --debug-dump来读取程序源码、类型信息等。

The readelf tool is good at showing you some details on the data:

$ readelf -a /usr/bin/readelf
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
...

Some of its abilities to inspect specific sections of the executable can come in handy too:

$ readelf -p .rodata /usr/bin/readelf | more

String dump of section '.rodata':
  [     4]  R_IA64_IMM14
  [    11]  R_IA64_NONE
  ...
  [  1f58]    Personality routine: 
  [  1f70]  __gcc_personality_v0
  [  1f85]  __gxx_personality_v0
  [  1f9a]  __gcj_personality_v0
  [  1faf]  __gnu_objc_personality_v0
  ...

Actually disassembling the code is a bit of a stretch; if you compile your code with -g for debugging symbols, you can use readelf --debug-dump to read the program source, type information, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文