3

给定来自 的两个 PE 对象文件cl.exe,一个 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

如果我安装msys2file实用程序可以理解它:

$ 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

filemsys2 的 pacman 做得更好的东西也可能很有趣。

4

1 回答 1

3

最直接的方法是使用微软的DUMPBIN工具,通过/HEADERS选项,例如

dumpbin /HEADERS cl.exe | findstr "machine"

这将为 64 位图像生成以下输出

            8664 machine (x64)

或以下用于 32 位图像

             14C machine (x86)
                   32 bit word machine
于 2017-01-20T18:23:50.947 回答