[英]Distinguish a 32bit from a 64bit PE object file generated by cl.exe (Visual Studio C++)
Given two PE object files from cl.exe
, one 32bit and one 64bit, how can I tell one from the other without resorting to unix utilities, and preferably on the commandline (cmd.exe or powershell)?给定来自
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
If I install msys2 the file
utility can sortof make sense of it:如果我安装msys2
file
实用程序可以理解它:
$ file test*.obj
test32.obj: Intel 80386 COFF object file, not stripped, 3 sections, [...]
test64.obj: data
file --version
is 5.28, but the newer 5.25 does not do any better. file --version
是 5.28,但较新的 5.25 并没有做得更好。 msys2 does not offer an objdump.exe
, but when copied to Linux it could properly tell these two files apart: 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
Something which does better than file
and is available via msys2's pacman might also be interesting.比
file
做得更好并且可以通过 msys2 的 pacman 获得的东西也可能很有趣。
The most straight forward way is to use Microsoft's DUMPBIN tool, passing the /HEADERS option, eg最直接的方法是使用微软的DUMPBIN工具,传递/HEADERS选项,例如
dumpbin /HEADERS cl.exe | findstr "machine"
This produces the following output for a 64-bit image这将为 64 位图像生成以下输出
8664 machine (x64)
or the following for a 32-bit image或以下用于 32 位图像
14C machine (x86)
32 bit word machine
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.