Disassemble Microsoft Visual Studio 2003 compiler output

后端 未结 1 528
时光说笑
时光说笑 2021-02-10 03:10

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:

asmfil         


        
1条回答
  •  攒了一身酷
    2021-02-10 03:36

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

    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 files produced with /GL will not be available to such linker utilities as EDITBIN and DUMPBIN.

    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).

    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.


    Original answer:

    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
    

    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.

    0 讨论(0)
提交回复
热议问题