2017-01-20 106 views
1

給定兩個來自cl.exe的PE對象文件,一個32位和一個64位,如何告訴另一個來自另一個而不使用使用unix實用程序,並最好在命令行(cmd.exe或PowerShell)?區分32位與由cl.exe生成的64位PE對象文件(Visual Studio C++)

C:\> "...\VC\bin\cl.exe" -c test.c   -Fotest32.obj 
C:\> "...\VC\bin\x86_amd64\cl.exe" -c test.c -Fotest64.obj 

如果我安裝msys2file實用程序可以sortof有意義的是:

$ file test*.obj 
test32.obj: Intel 80386 COFF object file, not stripped, 3 sections, [...] 
test64.obj: data 

file --version是5.28,但較新的5.25不做任何好轉。 msys2不提供objdump.exe,但是當拷貝到Linux它可以正確地告訴這兩個文件分開:

$ objdump -a test64.obj 
test64.obj:  file format pe-x86-64 
$ objdump -a test32.obj 
test32.obj:  file format pe-i386 

一些東西,確實優於file,可通過msys2的吃豆子也提供可能是有趣的。

+2

下面的微軟工具是'dumpbin'。 –

+0

跨網站副本:http://superuser.com/q/358434/29943 –

回答

2

最直接的方法是使用微軟的DUMPBIN工具,通過/HEADERS選項,例如,

dumpbin /HEADERS cl.exe | findstr "machine" 

這將產生以下輸出一個64位的圖像

  8664 machine (x64) 

或對於32位圖像

   14C machine (x86) 
        32 bit word machine 
相關問題