linux下如何判斷elf檔案是32位還是64位?
阿新 • • 發佈:2019-02-10
例如一個可執行檔案messy,我想知道這個是32位還是64位的,
可以用readelf 這個命令,引數為-h
在得到的ELF Header中有一項Magic, 這個其實包含很多資訊,而這個32位學是64位就對應這個Magic中的第五個值,當為02時即為64位,01即為32位
有興趣的可以試一下
readelf -h messy
ELF Header:Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x400df0
Start of program headers: 64 (bytes into file)
Start of section headers: 63304 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 8
Size of section headers: 64 (bytes)
Number of section headers: 38
Section header string table index: 35