拆开微软Visual Studio 2003中的编译器输出 [英] Disassemble Microsoft Visual Studio 2003 compiler output

查看:446
本文介绍了拆开微软Visual Studio 2003中的编译器输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到什么,我认为是由微软的Visual Studio 2003工具从目标文件输出奇怪的行为。在文件工具告诉我:

I'm seeing what I think is strange behaviour from object files output by the Microsoft Visual Studio 2003 tools. The file utility tells me:

asmfile.obj: 80386 COFF executable not stripped - version 30821

有关由汇编器创建的对象,但对物体C文件来了,我得到的只是:

For objects created by the assembler, but for objects coming from C files, I get just:

cfile.obj: data

使用微软的 DUMPBIN 实用程序和 objdump的我从Cygwin的话,我可以拆卸组装建造的文件,但我得到任何效用的C-内置文件中没有有用的结果。

Using Microsoft's dumpbin utility and the objdump I got from cygwin, I can disassemble the assembly-built file, but I get no useful results from either utility for the C-built files.

我有几个与此相关的差异问题:

I have a couple of questions related to this difference:


  1. 什么是由MSVC2003编译器生成的目标文件格式?

  2. 我怎么能反汇编目标文件?

我在得到在AT&放拆装特别感兴趣; T语法 - 我正在做一个大的源代码库的一个端口,使其与海湾合作委员会的工作,我想用这种方法作为一种快捷方式对于一些内联汇编程序的项目。

I am particularly interested in getting the disassembly in AT&T syntax - I'm doing a port of a large source base to make it work with GCC, and I would like to use this method as a shortcut for some of the inline assembly routines in the project.

编辑:添加一些更多的信息

Adding some more information.

当我运行 DUMPBIN 对这些文件中的一个没有给我的结果:

When I run dumpbin on one of these files gives me no results:

C:\> dumpbin /disasm Func.obj
Microsoft (R) COFF/PE Dumper Version 7.10.6030    
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file Func.obj

FileType: ANONYMOUS OBJECT

使用 objdump的,它提供了:

$ objdump -d Func.obj
objdump: Func.obj: File truncated

在从汇编建立了文件,我得到合理的结果。

On the files built from assembly, I get reasonable results.

再次编辑:添加命令行信息

Edit again: Adding command line information.

该汇编文件都建有一个命令行类似以下内容:

The assembly files are built with a command line resembling the following:

ml -nologo -W3 -WX -c -coff -FoAssemblyFile.obj -Zi -Cx AssemblyFile.asm

当自行执行

毫升说:

Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000.  All rights reserved.

的C文件都建有下面的命令:

The C files are built with the following command:

cl -nologo -W4 -WX -Gs32768 -GX -Gy -c -FdCFile.pdb -FoCFile.obj -Zi 
   -Gm -O1 -Oy- -Gy -GL -X CFile.c

有一些 -I -D 传递给选项毫升 CL ,但是我在这里省略了对它们的简洁。在 CL 选项描述的此处

There are some -I and -D options passed to ml and to cl, but I've omitted them for brevity here. The cl options are described here.

推荐答案

被添加到这个问题的基础上的CL命令行选项编辑:

Edit based on the cl command line options being added to the question:

我认为这个问题是使用 / GL 选项,它指定链接时code一代的优化会做的。从该选项的文档页面:

I think the problem is the use of the /GL option, which specifies that link-time code generation optimization will be done. from a doc page on that option:

OBJ与/ GL生成的文件将无法使用这些链接公用事业EDITBIN和DUMPBIN。

obj files produced with /GL will not be available to such linker utilities as EDITBIN and DUMPBIN.

使用此选项时,编译器生成的链接器可以对执行程序范围内的优化 .OBJ 文件 - 显然文件格式是专有的(也许它某处记载,但我怀疑不是)。

Using this option causes the compiler to generate .obj files that the linker can perform program-wide optimization on - apparently the file format is proprietary (maybe it's documented somewhere, but I suspect not).

/ GL 的文档(也称为整个程序优化,链接时code一代,或LTCG)包含有关互操作性的几个警告包含这些对象的文件 .OBJ 文件或库中。

The docs for /GL (also known as "whole program optimization", "link-time code generation", or LTCG) contain several warnings about interoperability of the .obj files or libraries containing such objects files.

原来的答复:

到底是在C源你试图拆卸obj文件怎么办?我得到使用下面的 DUMPBIN / DISASM test.obj 一个简单的'Hello World程序:

What exactly is in the C source for the .obj file you're trying to disassemble? I get the following using dumpbin /disasm test.obj for a simple 'hello world' program:

Microsoft (R) COFF/PE Dumper Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file test.obj

File Type: COFF OBJECT

_main:
  00000000: 55                 push        ebp
  00000001: 8B EC              mov         ebp,esp
  00000003: 6A 01              push        1
  00000005: 68 00 00 00 00     push        offset $SG4665
  0000000A: E8 00 00 00 00     call        _printf
  0000000F: 83 C4 08           add         esp,8
  00000012: 33 C0              xor         eax,eax
  00000014: 3B EC              cmp         ebp,esp
  00000016: E8 00 00 00 00     call        __RTC_CheckEsp
  0000001B: 5D                 pop         ebp
  0000001C: C3                 ret

  Summary

         7AC .debug$S
          30 .debug$T
          2F .drectve
           4 .rdata
           4 .rtc$IMZ
           4 .rtc$TMZ
          1D .text

请注意:这是利用和被VS2005提供的 DUMPBIN ,但我可以编一个 .OBJ 文件难以想象这些东西会从VS2003太大的改变。

Note: this is using an .obj file compiled by and a dumpbin provided by VS2005, but I can't imagine this stuff would have changed much from VS2003.

这篇关于拆开微软Visual Studio 2003中的编译器输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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