簡體   English   中英

區分 32 位和 cl.exe 生成的 64 位 PE 對象文件(Visual Studio C++)

[英]Distinguish a 32bit from a 64bit PE object file generated by cl.exe (Visual Studio C++)

給定來自cl.exe兩個 PE 對象文件,一個 32 位和一個 64 位,如何在求助於 unix 實用程序的情況下,最好是在命令行(cmd.exe 或 powershell)上區分一個和另一個?

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

如果我安裝msys2 file實用程序可以理解它:

$ 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 的 pacman 獲得的東西也可能很有趣。

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

dumpbin /HEADERS cl.exe | findstr "machine"

這將為 64 位圖像生成以下輸出

            8664 machine (x64)

或以下用於 32 位圖像

             14C machine (x86)
                   32 bit word machine

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM