如何从 Windows 机器检查 linux 文件(.so)是 32 位还是 64 位 [英] how to check a linux file(.so) is of 32 or 64 bit from windows machine

查看:85
本文介绍了如何从 Windows 机器检查 linux 文件(.so)是 32 位还是 64 位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了检查特定的 windows dll 是 32 位还是 64 位,读取 PE 头将产生所需的结果.但是需要找出 linux 文件 (.so) 是 32 位还是 64 位.

For Checking whether a particular windows dll is of 32 or 64 bit, reading PE header will yield the needed result. But there is a need to find whether a linux file (.so) is of 32 or 64 bit.

搜索时,找到有助于查找此信息的 linux shell 脚本或命令.但是我们需要从windows环境中找到这个.在 Windows 操作系统上运行的任何 Windows 命令或代码都应该能够提供此信息.

When searched, found linux shell scripts or commands which help to find this information. But we need to find this from a windows environment. Any windows commands or code which runs on Windows OS should be able to provide this info.

推荐答案

听起来您希望能够以编程方式进行检查,而不是依赖于安装 Cygwin(因为如果您只需要检查文件,那可能有点过头了地位).您可以通过在 magic 表(在 /usr/share/misc/magic在 Cygwin 上):

It sounds like you want to be able to check this programmatically, rather than rely on installing Cygwin (as that may be overkill if you just need to check the file status). You can mimic what the file command is doing by looking up the ELF section in the magic table (in /usr/share/misc/magic on 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 格式规则的确切语法,但在我看来可能需要检查第 5 个字节,32 位为 1,64 位为 2-位

I don't know the exact syntax of the magic format rules, but it looks to me like might need to check the 5th byte which will be 1 for 32-bit and 2 for 64-bit

这篇关于如何从 Windows 机器检查 linux 文件(.so)是 32 位还是 64 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆