简体   繁体   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++)

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.

相关问题 Visual Studio - C++ - 以 32 位或 64 位形式构建和运行应用程序 - 从适当的 ProgramFiles 目录加载 DLL - Visual Studio - C++ - build and run app as 32bit or 64bit - load DLL from appropripate ProgramFiles dir 32位Visual Studio生成64位可执行文件 - 32bit Visual Studio generate 64bit executable MS Visual Studio Professional 2013-C ++可以为32位和64位操作系统编译单个可执行文件吗? - MS Visual Studio Professional 2013 - C++ Compile single executable for 32bit and 64bit operating systems? Visual Studio何时生成32bit .obj文件和64bit .obj文件? - When Visual Studio generates 32bit .obj file and 64bit .obj file? Visual Studio在为32位编译时尝试使用64位C运行时库 - Visual Studio trying to use 64bit C runtime lib when compiling for 32bit 使用C ++从32位进程访问64位dll - access 64bit dll from 32bit process using C++ 从 32 位 c++ 程序读取 64 位注册表? - Reading 64bit registry from 32bit c++ program? C ++二进制写入/读取32位到/从64位 - C++ Binary Writing/Reading on 32bit to/from 64bit 在 MS VC 2013 Express 中将 C++ dll 从 32 位转换为 64 位 - Convert C++ dll from 32bit to 64bit in MS VC 2013 Express Windows 7 64位Visual Studio 2013上的本机cl.exe - Native cl.exe on Windows 7 64-bit Visual Studio 2013
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM