2013-10-18 122 views
1

對於檢查某個特定的Windows DLL是32位還是64位,讀PE頭將產生所需的結果。但是需要找到一個linux文件(.so)是32位還是64位。如何檢查Linux文件(.so)是32位還是64位從Windows機器

當搜索時,發現有助於查找此信息的linux shell腳本或命令。但是我們需要從Windows環境中找到它。在Windows操作系統上運行的任何Windows命令或代碼都應該能夠提供此信息。

+1

爲什麼不只是解析精靈標題? – stdcall

+2

不是.so只是ELF文件? (我不知道,不是linux)如果是這樣,在偏移4處有一個32位的字節和64位的2個字節 – harold

+0

你不能通過ssh來完成它嗎? 'ssh遠程機器文件my_file'? –

回答

2

最簡單的方法是安裝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 
4

這聽起來像你希望能夠以編程方式檢查這一點,而不是依賴於安裝Cygwin(因爲這可能是矯枉過正如果你只需要檢查文件狀態)。你可以模仿什麼file命令通過查找在magic表(在Cygwin中/usr/share/misc/magic)的ELF節做:

# 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個字節,這將是1對於32位和2對於64位

相關問題