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)?
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:
$ 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. msys2 does not offer an objdump.exe
, but when copied to Linux it could properly tell these two files apart:
$ 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.
The most straight forward way is to use Microsoft's DUMPBIN tool, passing the /HEADERS option, e.g.
dumpbin /HEADERS cl.exe | findstr "machine"
This produces the following output for a 64-bit image
8664 machine (x64)
or the following for a 32-bit image
14C machine (x86)
32 bit word machine