【问题标题】:Distinguish a 32bit from a 64bit PE object file generated by cl.exe (Visual Studio C++)区分 cl.exe 生成的 32 位和 64 位 PE 对象文件(Visual Studio C++)
【发布时间】:2017-01-20 18:13:55
【问题描述】:

给定来自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 获得的东西也可能很有趣。

【问题讨论】:

标签: c++ windows executable msys2 cl


【解决方案1】:

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

dumpbin /HEADERS cl.exe | findstr "machine"

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

            8664 machine (x64)

或以下对于 32 位图像

             14C machine (x86)
                   32 bit word machine

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-13
    • 1970-01-01
    • 2011-08-01
    • 2012-08-23
    • 2011-09-13
    相关资源
    最近更新 更多