Reputation: 6464
I want to verify if an object has been compiled in 32-bit or 64-bit:
% readelf -h my_obj
ELF Header:
Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, big endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
...
Since ELF32 is displayed, does this guarantee that the object is in 32-bit mode?
Upvotes: 2
Views: 7166
Reputation: 5765
Fat binaries aren't common or standard for ELF, so the class does reliably indicate 32 vs 64 bit. But to figure out whether you're looking at 32-bit x86, ARM, MIPS, or whatever, you have to also inspect the Machine field right below the Type field.
Upvotes: 2