用于检查特定的Windows DLL是否为32或64位,读PE头将产生所需要的结果。 但是,有必要找到是否linux文件(的.so)是32位还是64位的。
当搜查,发现linux的shell脚本或帮助查找此信息的命令。 但是,我们需要从Windows环境中找到。 它运行在Windows操作系统上的所有窗口的命令或代码应能提供这个信息。
用于检查特定的Windows DLL是否为32或64位,读PE头将产生所需要的结果。 但是,有必要找到是否linux文件(的.so)是32位还是64位的。
当搜查,发现linux的shell脚本或帮助查找此信息的命令。 但是,我们需要从Windows环境中找到。 它运行在Windows操作系统上的所有窗口的命令或代码应能提供这个信息。
这听起来像你希望能够以编程方式检查这一点,而不是依赖于安装Cygwin(因为这可能是矫枉过正,如果你只是需要检查文件状态)。 你可以模仿什么file
命令由在仰视ELF节做magic
表( /usr/share/misc/magic
在Cygwin):
# elf: file(1) magic for ELF executables
#
# We have to check the byte order flag to see what byte order all the
# other stuff in the header is in.
#
0 string \177ELF ELF
>4 byte 0 invalid class
>4 byte 1 32-bit
>4 byte 2 64-bit
>5 byte 0 invalid byte order
>5 byte 1 LSB
>>16 leshort 0 no file type,
!:strength *2
!:mime application/octet-stream
>>16 leshort 1 relocatable,
!:mime application/x-object
>>16 leshort 2 executable,
!:mime application/x-executable
>>16 leshort 3 shared object,
我不知道的确切语法magic
格式规则,但是在我看来像可能需要检查,这将是1对32位和2个64位的第5个字节
最简单的方法是安装的Cygwin和使用file
的命令:
$ file libc.so
libc.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared lib
s), BuildID[sha1]=0xdf6c83b270f1e32ea0482d61ae16933aa090870b, for GNU/Linux 2.6.24, stripped